documint 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -6
- package/dist/index.js +38 -35
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import{useEffect as
|
|
2
|
-
`);return{id:
|
|
3
|
-
`);return{align:$.align??[],id:
|
|
4
|
-
`;case"image":return
|
|
5
|
-
`);case"table":return
|
|
6
|
-
`);case"
|
|
7
|
-
`).trim()}function
|
|
8
|
-
`);return{id:
|
|
9
|
-
`);return{align:$.align,id:Y0("table",M,J),plainText:J,rows:Z,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 zX($,M){return{cells:$.cells.map((Z,J)=>{let X=Z.children.map((Q,K)=>Q5(Q,`${M}.cells.${J}.children.${K}`)),Y=X0(X);return{children:X,id:Y0("tableCell",`${M}.cells.${J}`,Y),plainText:Y}}),id:Y0("tableRow",M,String($.cells.length))}}function Q5($,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 Z=$.children.map((X,Y)=>Q5(X,`${M}.children.${Y}`)),J=X0(Z);return{children:Z,id:Y0("link",M,`${$.url}:${J}`),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 R2($){return $.map((M)=>{switch(M.type){case"blockquote":return{...M,children:R2(M.children)};case"heading":case"paragraph":return u0(M,j8(M.children));case"list":return{...M,items:M.items.map((Z)=>({...Z,children:R2(Z.children)}))};case"listItem":return{...M,children:R2(M.children)};case"table":return w0(M,M.rows.map((Z)=>({...Z,cells:Z.cells.map((J)=>({...J,children:j8(J.children)}))})));default:return M}})}function j8($){let M=[...$];for(let Z=M.length-1;Z>=0;Z-=1){let J=M[Z];if(J.type==="text"){let X=J.text.replace(/[ \t]+$/u,"");if(X.length===J.text.length)return M;if(X.length===0){M.splice(Z,1);continue}return M[Z]={...J,text:X},M}if(J.type==="link"){let X=j8(J.children);if(X.length===J.children.length&&X.every((Y,Q)=>Y===J.children[Q]))return M;if(X.length===0){M.splice(Z,1);continue}return M[Z]={...J,children:X},M}return M}return M}function Y0($,M,Z){let J=2166136261;for(let X of`${$}:${M}:${Z}`)J^=X.charCodeAt(0),J=Math.imul(J,16777619);return`${$}-${(J>>>0).toString(36)}`}function L8($,M){C8($.blocks,M,R9(),S9())}function HX($,M){C8($,M,R9(),S9())}function s1($,M){let Z=null,J={enterBlock(X){if(X.id===M)return Z=X,"stop"}};if(Array.isArray($))HX($,J);else L8($,J);return Z}function C8($,M,Z,J){for(let[X,Y]of $.entries()){if(Z.stopped)return;let Q=`${J.pathPrefix}.${X}`,K={blockAncestors:J.blockAncestors,depth:J.depth,parentBlock:J.parentBlock,path:Q},q=M.enterBlock?.(Y,K);if(i1(q,Z))return;if(q!=="skip")switch(Y.type){case"list":C9(Y.items,Y,M,Z,J,Q);break;case"blockquote":case"listItem":C9(Y.children,Y,M,Z,J,Q);break;case"heading":case"paragraph":R8(Y.children,M,Z,{block:Y,blockAncestors:[...J.blockAncestors,Y],inlineAncestors:[],parentInline:null,pathPrefix:`${Q}.children`});break;case"table":WX(Y,M,Z,{blockAncestors:[...J.blockAncestors,Y],pathPrefix:Q});break;case"code":case"directive":case"thematicBreak":case"unsupported":break}if(Z.stopped)return;if(i1(M.leaveBlock?.(Y,K),Z))return}}function R8($,M,Z,J){for(let[X,Y]of $.entries()){if(Z.stopped)return;let Q=`${J.pathPrefix}.${X}`,K={block:J.block,blockAncestors:J.blockAncestors,inlineAncestors:J.inlineAncestors,parentInline:J.parentInline,path:Q},q=M.enterInline?.(Y,K);if(i1(q,Z))return;if(q!=="skip"){if(Y.type==="link")EX(Y.children,Y,M,Z,J,Q)}if(Z.stopped)return;if(i1(M.leaveInline?.(Y,K),Z))return}}function R9(){return{stopped:!1}}function S9(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function C9($,M,Z,J,X,Y){C8($,Z,J,{blockAncestors:[...X.blockAncestors,M],depth:X.depth+1,parentBlock:M,pathPrefix:`${Y}.children`})}function EX($,M,Z,J,X,Y){R8($,Z,J,{block:X.block,blockAncestors:X.blockAncestors,inlineAncestors:[...X.inlineAncestors,M],parentInline:M,pathPrefix:`${Y}.children`})}function WX($,M,Z,J){for(let[X,Y]of $.rows.entries())for(let[Q,K]of Y.cells.entries()){if(Z.stopped)return;let q=`${J.pathPrefix}.rows.${X}.cells.${Q}`,D={blockAncestors:J.blockAncestors,cellIndex:Q,path:q,row:Y,rowIndex:X,table:$},V=M.enterTableCell?.(K,D);if(i1(V,Z))return;if(V!=="skip")R8(K.children,M,Z,{block:$,blockAncestors:J.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${q}.children`});if(Z.stopped)return;if(i1(M.leaveTableCell?.(K,D),Z))return}}function i1($,M){if($!=="stop")return!1;return M.stopped=!0,!0}var S8="text";function k8($){return $==="text"||$==="code"||$==="tableCell"}function m8($){return $===S8?void 0:$}function m9($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function D5($){let M=[];return L8($,{enterBlock(Z){switch(Z.type){case"heading":case"paragraph":M.push({containerKind:"text",containerOrdinal:M.length,id:Z.id,text:X0(Z.children)});break;case"code":M.push({containerKind:"code",containerOrdinal:M.length,id:Z.id,text:Z.source});break}},enterTableCell(Z){M.push({containerKind:"tableCell",containerOrdinal:M.length,id:Z.id,text:X0(Z.children)})}}),M}function f8($,M,Z){return{prefix:$.slice(Math.max(0,M-k9),M),suffix:$.slice(Z,Math.min($.length,Z+k9))}}function S2($,M,Z){let J=O0(M,0,$.text.length),X=O0(Z,J,$.text.length),{prefix:Y,suffix:Q}=f8($.text,J,X);return{kind:m8($.containerKind),prefix:Y||void 0,suffix:Q||void 0}}function k2($,M,Z){let J=O0(M,0,$.text.length),X=O0(Z,J,$.text.length);return $.text.slice(J,X)}function h0($,M){if(M.length===0)return[];let Z=[],J=0;while(J<=$.length){let X=$.indexOf(M,J);if(X===-1)break;Z.push(X),J=X+Math.max(1,M.length)}return Z}function o1($,M,Z){if(M.length===0||Z.length===0)return[];let J=[];for(let X of h0($,M)){let Y=X+M.length,Q=$.indexOf(Z,Y);if(Q!==-1)J.push({startOffset:Y,endOffset:Q})}return J}function v8($,M,Z){if(!M)return!1;return $.slice(Math.max(0,Z-M.length),Z)===M}function u8($,M,Z){if(!M)return!1;return $.slice(Z,Z+M.length)===M}var k9=24;function O0($,M,Z){return Math.min(Math.max($,M),Z)}var f9=48,v9=64,yX=32;function m2($,M){let Z=$.anchor.kind??S8,J=D5(M).filter((Q)=>Q.containerKind===Z),X=BX($,J);if(X.length>0)return u9($,X,null);let Y=PX($,J);if(Y.length>0)return u9($,Y,"repaired");return{match:null,repair:null,status:"stale"}}function BX($,M){let Z=[],J=$.quote;if(J.length===0)return Z;for(let X of M)for(let Y of h0(X.text,J))Z.push({container:X,endOffset:Y+J.length,score:TX($,X,Y),startOffset:Y});return Z.sort((X,Y)=>Y.score-X.score),Z}function PX($,M){let Z=[];for(let J of M)Z.push(...wX($,J));return Z.sort((J,X)=>X.score-J.score),Z}function wX($,M){let Z=[],J=$.quote.length,X=M.text,Y=$.anchor.prefix??"",Q=$.anchor.suffix??"";if(Y.length>0&&Q.length>0){for(let K of o1(X,Y,Q))Z.push({container:M,endOffset:K.endOffset,score:h8($,M,K.startOffset,K.endOffset,J),startOffset:K.startOffset});return Z}if(Y.length>0){for(let K of h0(X,Y)){let q=K+Y.length,D=O0(q+J,q,X.length);Z.push({container:M,endOffset:D,score:h8($,M,q,D,J),startOffset:q})}return Z}if(Q.length>0)for(let K of h0(X,Q)){let q=K,D=O0(q-J,0,q);Z.push({container:M,endOffset:q,score:h8($,M,D,q,J),startOffset:D})}return Z}function u9($,M,Z){let[J,X]=M;if(!J)return{match:null,repair:null,status:"stale"};if(X&&J.score===X.score)return{match:null,repair:null,status:"ambiguous"};let Y=S2(J.container,J.startOffset,J.endOffset),Q=k2(J.container,J.startOffset,J.endOffset),K=Z??(Q===$.quote&&(Y.prefix??"")===($.anchor.prefix??"")&&(Y.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:bX(J.container,J.startOffset,J.endOffset),repair:{anchor:Y,quote:Q},status:K}}function bX($,M,Z){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:Z,startOffset:M}}function TX($,M,Z){let J=0;if(v8(M.text,$.anchor.prefix,Z))J+=f9;if(u8(M.text,$.anchor.suffix,Z+$.quote.length))J+=f9;return J}function h8($,M,Z,J,X){let Y=0;if(v8(M.text,$.anchor.prefix,Z))Y+=v9;if(u8(M.text,$.anchor.suffix,J))Y+=v9;if(Y+=Math.max(0,yX-Math.abs(X-(J-Z))),$.quote.length>0){let Q=M.text.slice(Z,J);if(Q.length>0)Y+=jX($.quote,Q),Y+=OX($.quote,Q)}return Y}function jX($,M){let Z=0;while(Z<$.length&&Z<M.length&&$[Z]===M[Z])Z+=1;return Z}function OX($,M){let Z=0;while(Z<$.length&&Z<M.length&&$[$.length-1-Z]===M[M.length-1-Z])Z+=1;return Z}function I8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let M=$,Z=CX(M.anchor),J=typeof M.quote==="string"?M.quote:null,X=Array.isArray(M.comments)?M.comments.flatMap((Y)=>{let Q=LX(Y);return Q?[Q]:[]}):[];if(!Z||!J||X.length===0)return null;return{quote:J,anchor:Z,comments:X,resolvedAt:typeof M.resolvedAt==="string"?M.resolvedAt:void 0}}function LX($){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 CX($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:M,prefix:Z,suffix:J}=$;if("kind"in $&&!k8(M)||"prefix"in $&&typeof Z!=="string"||"suffix"in $&&typeof J!=="string")return null;return{kind:k8(M)?m8(M):void 0,prefix:typeof Z==="string"?Z:void 0,suffix:typeof J==="string"?J:void 0}}function g8($){let M=$.createdAt??new Date().toISOString();return{comments:[h9({body:$.body,updatedAt:M})],quote:$.quote,anchor:$.anchor}}function p8($,M){let Z=h9(M);return{...$,comments:[...$.comments,Z]}}function l8($,M,Z,J=new Date().toISOString()){let X=Z.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:J}});if(!Y)return $;return{...$,comments:Q}}function x8($,M){let Z=$.comments.filter((J,X)=>X!==M);if(Z.length===$.comments.length)return $;if(Z.length===0)return null;return{...$,comments:Z}}function d8($,M,Z=new Date().toISOString()){if(X1($)===M)return $;return{...$,resolvedAt:M?Z:void 0}}function X1($){return $.resolvedAt!=null}function r8($){return $.filter((M)=>X1(M)).length}function c8($){if($.comments.length===0)return null;return $.comments.reduce((M,Z)=>Z.updatedAt>M?Z.updatedAt:M,$.comments[0].updatedAt)}function h9($){let M=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:M}}var RX=240,SX=0.5625,kX=120,I9=48;function q5($,M,Z){let J=$.image?M.images.get($.image.url)??null:null,X=$.image?.width??null,Y=Math.min(Z,X??RX),Q=Math.max(kX,Math.round(Y*SX));if(!J||J.intrinsicWidth<=0||J.intrinsicHeight<=0)return{height:Q,width:Y};let K=Math.min(Z,X??J.intrinsicWidth),q=Math.min(1,K/J.intrinsicWidth);return{height:Math.max(I9,Math.round(J.intrinsicHeight*q)),width:Math.max(I9,Math.round(J.intrinsicWidth*q))}}function V5($,M,Z,J){let X=$.documentIndex.regionIndex.get($.selection.anchor.regionId);if(!J.image||!X)return null;let Y=L0(M.layout,X.id,J.start);if(!Y)return null;let Q=Y.left+I0($,Y),K=Q+y0(Y,J.start-Y.start)-Y.left,q=Q+y0(Y,J.end-Y.start)-Y.left,{height:D}=q5(J,Z,Y.width),V=Y.top+Math.max(0,Math.floor((Y.height-D)/2));return{left:K,top:V,width:q-K,height:D}}function g9($,M){if(!$.image)return`${$.kind}:missing-image`;let Z=M.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${Z?.status??"loading"}:${Z?.intrinsicWidth??0}:${Z?.intrinsicHeight??0}`}function b1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function p9($,M,Z){return f2($.preparedText,M,Z,256)}function l9($,M,Z){return f2($.measuredLines,M,Z,512)}function x9($,M,Z){return f2($.lineBoundaries,M,Z,1024)}function d9($,M,Z){return f2($.measuredContainerHeights,M,Z,1024)}function r9($,M){let Z=$.graphemeWidths.get(M);if(Z)return Z;let J=new Map;return f2($.graphemeWidths,M,J,64),J}function c9($,M,Z){return $.viewportPlans.get(M)?.get(Z)??null}function a9($,M,Z,J){let X=$.viewportPlans.get(M)??new Map;return X.set(Z,J),$.viewportPlans.set(M,X),J}function f2($,M,Z,J){if($.has(M))$.delete(M);if($.set(M,Z),$.size>J){let X=$.keys().next().value;if(X!==void 0)$.delete(X)}return Z}var mX=["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"],fX=["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 vX($){if($<=255)return mX[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return fX[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function uX($){let M=$.length;if(M===0)return null;let Z=Array(M),J=0;for(let D=0;D<M;D++){let V=vX($.charCodeAt(D));if(V==="R"||V==="AL"||V==="AN")J++;Z[D]=V}if(J===0)return null;let X=M/J<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(Z[D]==="NSM")Z[D]=q;else q=Z[D];q=K;for(let D=0;D<M;D++){let V=Z[D];if(V==="EN")Z[D]=q==="AL"?"AN":"EN";else if(V==="R"||V==="L"||V==="AL")q=V}for(let D=0;D<M;D++)if(Z[D]==="AL")Z[D]="R";for(let D=1;D<M-1;D++){if(Z[D]==="ES"&&Z[D-1]==="EN"&&Z[D+1]==="EN")Z[D]="EN";if(Z[D]==="CS"&&(Z[D-1]==="EN"||Z[D-1]==="AN")&&Z[D+1]===Z[D-1])Z[D]=Z[D-1]}for(let D=0;D<M;D++){if(Z[D]!=="EN")continue;let V;for(V=D-1;V>=0&&Z[V]==="ET";V--)Z[V]="EN";for(V=D+1;V<M&&Z[V]==="ET";V++)Z[V]="EN"}for(let D=0;D<M;D++){let V=Z[D];if(V==="WS"||V==="ES"||V==="ET"||V==="CS")Z[D]="ON"}q=K;for(let D=0;D<M;D++){let V=Z[D];if(V==="EN")Z[D]=q==="L"?"L":"EN";else if(V==="R"||V==="L")q=V}for(let D=0;D<M;D++){if(Z[D]!=="ON")continue;let V=D+1;while(V<M&&Z[V]==="ON")V++;let G=D>0?Z[D-1]:K,U=V<M?Z[V]:K,A=G!=="L"?"R":"L";if(A===(U!=="L"?"R":"L"))for(let N=D;N<V;N++)Z[N]=A;D=V-1}for(let D=0;D<M;D++)if(Z[D]==="ON")Z[D]=Q;for(let D=0;D<M;D++){let V=Z[D];if((Y[D]&1)===0){if(V==="R")Y[D]++;else if(V==="AN"||V==="EN")Y[D]+=2}else if(V==="L"||V==="AN"||V==="EN")Y[D]++}return Y}function i9($,M){let Z=uX($);if(Z===null)return null;let J=new Int8Array(M.length);for(let X=0;X<M.length;X++)J[X]=Z[M[X]];return J}var hX=/[ \t\n\r\f]+/g,IX=/[\t\n\r\f]| {2,}|^ | $/;function gX($){let M=$??"normal";return M==="pre-wrap"?{mode:M,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:M,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function pX($){if(!IX.test($))return $;let M=$.replace(hX," ");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 lX($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
1
|
+
import{useEffect as h2,useEffectEvent as k2,useLayoutEffect as pA,useMemo as M1,useRef as r1,useState as k9}from"react";function x0($){let Y=X0($.children);return{children:$.children,id:U0($.path,"paragraph",Y),plainText:Y,type:"paragraph"}}function i($){return x0({children:r9(void 0,$.text)})}function H5($){let Y=X0($.children);return{children:$.children,depth:$.depth,id:U0($.path,"heading",`${$.depth}:${Y}`),plainText:Y,type:"heading"}}function t1($){return H5({children:r9(void 0,$.text),depth:$.depth})}function q1($){let Y=$.marks??[];return{id:U0($.path,"text",`${$.text}:${Y.join(",")}`),marks:Y,text:$.text,type:"text"}}function l0($={}){return{id:U0($.path,"lineBreak","lineBreak"),type:"lineBreak"}}function e1($){return{code:$.code,id:U0($.path,"code",$.code),type:"code"}}function $2($){return{children:$.children,id:U0($.path,"link",`${$.url}:${X0($.children)}`),title:$.title??null,type:"link",url:$.url}}function j1($){let Y=$.alt??null,X=$.width??null;return{alt:Y,id:U0($.path,"image",`${$.url}:${X??""}:${Y??""}`),title:$.title??null,type:"image",url:$.url,width:X}}function z5($){return{id:U0($.path,"raw",$.source),originalType:$.originalType,source:$.source,type:"raw"}}function w1($){let Y=C1($.children);return{checked:$.checked??null,children:$.children,id:U0($.path,"listItem",Y),plainText:Y,spread:$.spread??!1,type:"listItem"}}function O1($){let Y=$.items.map((X)=>X.plainText).join(`
|
|
2
|
+
`);return{id:U0($.path,"list",`${String($.ordered)}:${Y}`),items:$.items,ordered:$.ordered,plainText:Y,spread:$.spread??!1,start:$.start??null,type:"list"}}function R0($){let Y=C1($.children);return{children:$.children,id:U0($.path,"blockquote",Y),plainText:Y,type:"blockquote"}}function t6($){return{id:U0($.path,"code",`${$.language??""}:${$.source}`),language:$.language??null,meta:$.meta??null,plainText:$.source,source:$.source,type:"code"}}function D1($){let Y=X0($.children);return{children:$.children,id:U0($.path,"tableCell",Y),plainText:Y}}function Y2($){return{cells:$.cells,id:U0($.path,"tableRow",String($.cells.length))}}function B1($){let Y=$.rows.map((X)=>X.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
3
|
+
`);return{align:$.align??[],id:U0($.path,"table",Y),plainText:Y,rows:$.rows,type:"table"}}function F5(){return{id:"",plainText:"",type:"divider"}}function e6($){return{id:U0($.path,"raw",$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"raw"}}function a9($){return{attributes:$.attributes,body:$.body,id:U0($.path,"directive",`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"}}function Z0($){let Y=[];for(let X of $){let Z=Y.at(-1);if(Z?.type==="text"&&X.type==="text"&&Z.marks.join(",")===X.marks.join(",")){Y[Y.length-1]=q1({marks:Z.marks,path:Z.id,text:Z.text+X.text});continue}Y.push(X)}return Y}function O0($,Y){return $.type==="heading"?H5({children:Y,depth:$.depth}):x0({children:Y})}function d0($,Y){return w1({checked:$.checked,children:Y,spread:$.spread})}function M0($,Y,X={}){return O1({items:Y,ordered:X.ordered??$.ordered,spread:X.spread??$.spread,start:X.start??$.start})}function B0($,Y){return B1({align:$.align,rows:Y})}function g2($,Y){return t6({language:$.language,meta:$.meta,source:Y})}function I2($,Y){return e6({originalType:$.originalType,source:Y})}function r9($,Y){return Y.length>0?[q1({path:$?`${$}.children.0`:void 0,text:Y})]:[]}function U0($,Y,X){return $?J0(Y,$,X):""}function $8($,Y){Y8($.blocks,Y,i9(),o9())}function NK($,Y){Y8($,Y,i9(),o9())}function c0($,Y){let X=null,Z={enterBlock(J){if(J.id===Y)return X=J,"stop"}};if(Array.isArray($))NK($,Z);else $8($,Z);return X}function Y8($,Y,X,Z){for(let[J,K]of $.entries()){if(X.stopped)return;let Q=`${Z.pathPrefix}.${J}`,M={blockAncestors:Z.blockAncestors,depth:Z.depth,parentBlock:Z.parentBlock,path:Q},D=Y.enterBlock?.(K,M);if(X2(D,X))return;if(D!=="skip")switch(K.type){case"list":s9(K.items,K,Y,X,Z,Q);break;case"blockquote":case"listItem":s9(K.children,K,Y,X,Z,Q);break;case"heading":case"paragraph":X8(K.children,Y,X,{block:K,blockAncestors:[...Z.blockAncestors,K],inlineAncestors:[],parentInline:null,pathPrefix:`${Q}.children`});break;case"table":_K(K,Y,X,{blockAncestors:[...Z.blockAncestors,K],pathPrefix:Q});break;case"code":case"directive":case"divider":case"raw":break}if(X.stopped)return;if(X2(Y.leaveBlock?.(K,M),X))return}}function X8($,Y,X,Z){for(let[J,K]of $.entries()){if(X.stopped)return;let Q=`${Z.pathPrefix}.${J}`,M={block:Z.block,blockAncestors:Z.blockAncestors,inlineAncestors:Z.inlineAncestors,parentInline:Z.parentInline,path:Q},D=Y.enterInline?.(K,M);if(X2(D,X))return;if(D!=="skip"){if(K.type==="link")AK(K.children,K,Y,X,Z,Q)}if(X.stopped)return;if(X2(Y.leaveInline?.(K,M),X))return}}function i9(){return{stopped:!1}}function o9(){return{blockAncestors:[],depth:0,parentBlock:null,pathPrefix:"root"}}function s9($,Y,X,Z,J,K){Y8($,X,Z,{blockAncestors:[...J.blockAncestors,Y],depth:J.depth+1,parentBlock:Y,pathPrefix:`${K}.children`})}function AK($,Y,X,Z,J,K){X8($,X,Z,{block:J.block,blockAncestors:J.blockAncestors,inlineAncestors:[...J.inlineAncestors,Y],parentInline:Y,pathPrefix:`${K}.children`})}function _K($,Y,X,Z){for(let[J,K]of $.rows.entries())for(let[Q,M]of K.cells.entries()){if(X.stopped)return;let D=`${Z.pathPrefix}.rows.${J}.cells.${Q}`,q={blockAncestors:Z.blockAncestors,cellIndex:Q,path:D,row:K,rowIndex:J,table:$},U=Y.enterTableCell?.(M,q);if(X2(U,X))return;if(U!=="skip")X8(M.children,Y,X,{block:$,blockAncestors:Z.blockAncestors,inlineAncestors:[],parentInline:null,pathPrefix:`${D}.children`});if(X.stopped)return;if(X2(Y.leaveTableCell?.(M,q),X))return}}function X2($,Y){if($!=="stop")return!1;return Y.stopped=!0,!0}function Z2($,Y,X="root",Z=null){let J=!1,K=[];for(let[Q,M]of $.entries()){let D=`${X}.${Q}`,q=Y(M,{parent:Z,path:D,recurse:()=>HK(M,Y,`${D}.children`)});if(q===null){J=!0;continue}if(Array.isArray(q)){J=!0,K.push(...q);continue}if(q!==M)J=!0;K.push(q)}return J?K:$}function HK($,Y,X){switch($.type){case"blockquote":case"listItem":{let Z=Z2($.children,Y,X,$);return Z===$.children?$:{...$,children:Z}}case"list":{let Z=Z2($.items,Y,X,$);return Z===$.items?$:{...$,items:Z}}default:return $}}function J2($,Y=[],X){return{blocks:$.map((Z,J)=>J8(Z,J)),comments:Y,frontMatter:X}}function L1($,Y,X,Z){let J=Z.map((M,D)=>J8(M,Y+D)),K=$.blocks.slice(Y+X),Q=Z.length===X?K:K.map((M,D)=>J8(M,Y+J.length+D));return{blocks:[...$.blocks.slice(0,Y),...J,...Q],comments:$.comments,frontMatter:$.frontMatter}}function t9($,Y,X,Z){return{blocks:$.blocks,comments:[...$.comments.slice(0,Y),...Z,...$.comments.slice(Y+X)],frontMatter:$.frontMatter}}function e9($,Y,X,Z){if(Z!==void 0)return n9($,Z,Y,X);for(let J=0;J<$.blocks.length;J+=1){let K=n9($,J,Y,X);if(K)return K}return null}function n9($,Y,X,Z){let J=$.blocks[Y];if(!J)return null;let K=$7(J,X,Z);return K?L1($,Y,1,[K]):null}function $7($,Y,X){if($.id===Y)return X($);switch($.type){case"blockquote":{let Z=Z8($.children,Y,X);return Z?R0({children:Z}):null}case"listItem":{let Z=Z8($.children,Y,X);return Z?d0($,Z):null}case"list":{let Z=Z8($.items,Y,X);return Z?M0($,Z):null}default:return null}}function Z8($,Y,X){let Z=!1,J=$.map((K)=>{let Q=$7(K,Y,X);if(!Q)return K;return Z=!0,Q});return Z?J:null}function X0($){return $.map((Y)=>{switch(Y.type){case"lineBreak":return`
|
|
4
|
+
`;case"image":return Y.alt??"";case"code":return Y.code;case"link":return X0(Y.children);case"text":return Y.text;case"raw":return Y.source}}).join("")}function C1($){return $.map((Y)=>{switch(Y.type){case"blockquote":case"listItem":return C1(Y.children);case"code":return Y.source;case"directive":return Y.body;case"heading":case"paragraph":return X0(Y.children);case"list":return Y.items.map((X)=>X.plainText).join(`
|
|
5
|
+
`);case"table":return Y.rows.map((X)=>X.cells.map((Z)=>Z.plainText).join(" | ")).join(`
|
|
6
|
+
`);case"divider":return"";case"raw":return Y.source}}).join(`
|
|
7
|
+
`).trim()}function Q8($){return $.every((Y)=>Y.type==="text"&&Y.marks.length===0)}function P5($){if($.length!==1)return!1;let Y=$[0];return Y.type==="paragraph"&&Q8(Y.children)}function Y7($){switch($.kind){case"text":return $.text;case"inlines":return X0($.inlines);case"blocks":return C1($.blocks)}}function _0($){switch($.type){case"blockquote":case"listItem":return $.children;case"list":return $.items;default:return null}}function R1($,Y){if(Y.length===0)return null;switch($.type){case"blockquote":return R0({children:Y});case"list":return M0($,Y);case"listItem":return d0($,Y);default:return null}}function J8($,Y){return E5($,`root.${Y}`)}function E5($,Y){switch($.type){case"blockquote":{let X=$.children.map((J,K)=>E5(J,`${Y}.children.${K}`)),Z=C1(X);return{children:X,id:J0("blockquote",Y,Z),plainText:Z,type:"blockquote"}}case"code":return{id:J0("code",Y,`${$.language??""}:${$.source}`),language:$.language,meta:$.meta,plainText:$.source,source:$.source,type:"code"};case"directive":return{attributes:$.attributes,body:$.body,id:J0("directive",Y,`${$.name}{${$.attributes}}:${$.body}`),name:$.name,plainText:$.body,type:"directive"};case"heading":{let X=$.children.map((J,K)=>W5(J,`${Y}.children.${K}`)),Z=X0(X);return{children:X,depth:$.depth,id:J0("heading",Y,`${$.depth}:${Z}`),plainText:Z,type:"heading"}}case"list":{let X=$.items.map((J,K)=>E5(J,`${Y}.children.${K}`)),Z=X.map((J)=>J.plainText).join(`
|
|
8
|
+
`);return{id:J0("list",Y,`${String($.ordered)}:${Z}`),items:X,ordered:$.ordered,plainText:Z,spread:$.spread,start:$.start,type:"list"}}case"listItem":{let X=$.children.map((J,K)=>E5(J,`${Y}.children.${K}`)),Z=C1(X);return{checked:$.checked,children:X,id:J0("listItem",Y,Z),plainText:Z,spread:$.spread,type:"listItem"}}case"paragraph":{let X=$.children.map((J,K)=>W5(J,`${Y}.children.${K}`)),Z=X0(X);return{children:X,id:J0("paragraph",Y,Z),plainText:Z,type:"paragraph"}}case"table":{let X=$.rows.map((J,K)=>zK(J,`${Y}.rows.${K}`)),Z=X.map((J)=>J.cells.map((K)=>K.plainText).join(" | ")).join(`
|
|
9
|
+
`);return{align:$.align,id:J0("table",Y,Z),plainText:Z,rows:X,type:"table"}}case"divider":return{id:J0("divider",Y,"divider"),plainText:"",type:"divider"};case"raw":return{id:J0("raw",Y,$.source),originalType:$.originalType,plainText:$.source,source:$.source,type:"raw"}}}function zK($,Y){return{cells:$.cells.map((X,Z)=>{let J=X.children.map((Q,M)=>W5(Q,`${Y}.cells.${Z}.children.${M}`)),K=X0(J);return{children:J,id:J0("tableCell",`${Y}.cells.${Z}`,K),plainText:K}}),id:J0("tableRow",Y,String($.cells.length))}}function W5($,Y){switch($.type){case"lineBreak":return{id:J0("lineBreak",Y,"lineBreak"),type:"lineBreak"};case"image":return{alt:$.alt,id:J0("image",Y,`${$.url}:${$.width??""}:${$.alt??""}`),title:$.title,type:"image",url:$.url,width:$.width};case"code":return{code:$.code,id:J0("code",Y,$.code),type:"code"};case"link":{let X=$.children.map((J,K)=>W5(J,`${Y}.children.${K}`)),Z=X0(X);return{children:X,id:J0("link",Y,`${$.url}:${Z}`),title:$.title,type:"link",url:$.url}}case"text":return{id:J0("text",Y,`${$.text}:${$.marks.join(",")}`),marks:$.marks,text:$.text,type:"text"};case"raw":return{id:J0("raw",Y,$.source),originalType:$.originalType,source:$.source,type:"raw"}}}function X7($){return Z2($,(Y,{recurse:X})=>{switch(Y.type){case"blockquote":case"list":case"listItem":return X();case"heading":case"paragraph":return O0(Y,K8(Y.children));case"table":return B0(Y,Y.rows.map((Z)=>({...Z,cells:Z.cells.map((J)=>({...J,children:K8(J.children)}))})));default:return Y}})}function K8($){let Y=null,X=()=>Y??=[...$];for(let Z=$.length-1;Z>=0;Z-=1){let J=$[Z];if(J.type==="text"){let K=J.text.replace(/[ \t]+$/u,"");if(K.length===J.text.length)return Y??$;let Q=X();if(K.length===0){Q.splice(Z,1);continue}return Q[Z]={...J,text:K},Q}if(J.type==="link"){let K=K8(J.children);if(K===J.children)return Y??$;let Q=X();if(K.length===0){Q.splice(Z,1);continue}return Q[Z]={...J,children:K},Q}return Y??$}return Y??$}function J0($,Y,X){let Z=2166136261;for(let J of`${$}:${Y}:${X}`)Z^=J.charCodeAt(0),Z=Math.imul(Z,16777619);return`${$}-${(Z>>>0).toString(36)}`}var M8="text";function q8($){return $==="text"||$==="code"||$==="tableCell"}function D8($){return $===M8?void 0:$}function J7($){switch($){case"heading":case"paragraph":return"text";case"code":return"code";default:return null}}function y5($){let Y=[];return $8($,{enterBlock(X){switch(X.type){case"heading":case"paragraph":Y.push({containerKind:"text",containerOrdinal:Y.length,id:X.id,text:X0(X.children)});break;case"code":Y.push({containerKind:"code",containerOrdinal:Y.length,id:X.id,text:X.source});break}},enterTableCell(X){Y.push({containerKind:"tableCell",containerOrdinal:Y.length,id:X.id,text:X0(X.children)})}}),Y}function U8($,Y,X){return{prefix:$.slice(Math.max(0,Y-Z7),Y),suffix:$.slice(X,Math.min($.length,X+Z7))}}function p2($,Y,X){let Z=b0(Y,0,$.text.length),J=b0(X,Z,$.text.length),{prefix:K,suffix:Q}=U8($.text,Z,J);return{kind:D8($.containerKind),prefix:K||void 0,suffix:Q||void 0}}function x2($,Y,X){let Z=b0(Y,0,$.text.length),J=b0(X,Z,$.text.length);return $.text.slice(Z,J)}function a0($,Y){if(Y.length===0)return[];let X=[],Z=0;while(Z<=$.length){let J=$.indexOf(Y,Z);if(J===-1)break;X.push(J),Z=J+Math.max(1,Y.length)}return X}function K2($,Y,X){if(Y.length===0||X.length===0)return[];let Z=[];for(let J of a0($,Y)){let K=J+Y.length,Q=$.indexOf(X,K);if(Q!==-1)Z.push({startOffset:K,endOffset:Q})}return Z}function G8($,Y,X){if(!Y)return!1;return $.slice(Math.max(0,X-Y.length),X)===Y}function V8($,Y,X){if(!Y)return!1;return $.slice(X,X+Y.length)===Y}var Z7=24;function b0($,Y,X){return Math.min(Math.max($,Y),X)}var K7=48,Q7=64,FK=32;function l2($,Y){let X=$.anchor.kind??M8,Z=y5(Y).filter((Q)=>Q.containerKind===X),J=EK($,Z);if(J.length>0)return M7($,J,null);let K=WK($,Z);if(K.length>0)return M7($,K,"repaired");return{match:null,repair:null,status:"stale"}}function EK($,Y){let X=[],Z=$.quote;if(Z.length===0)return X;for(let J of Y)for(let K of a0(J.text,Z))X.push({container:J,endOffset:K+Z.length,score:TK($,J,K),startOffset:K});return X.sort((J,K)=>K.score-J.score),X}function WK($,Y){let X=[];for(let Z of Y)X.push(...PK($,Z));return X.sort((Z,J)=>J.score-Z.score),X}function PK($,Y){let X=[],Z=$.quote.length,J=Y.text,K=$.anchor.prefix??"",Q=$.anchor.suffix??"";if(K.length>0&&Q.length>0){for(let M of K2(J,K,Q))X.push({container:Y,endOffset:M.endOffset,score:N8($,Y,M.startOffset,M.endOffset,Z),startOffset:M.startOffset});return X}if(K.length>0){for(let M of a0(J,K)){let D=M+K.length,q=b0(D+Z,D,J.length);X.push({container:Y,endOffset:q,score:N8($,Y,D,q,Z),startOffset:D})}return X}if(Q.length>0)for(let M of a0(J,Q)){let D=M,q=b0(D-Z,0,D);X.push({container:Y,endOffset:D,score:N8($,Y,q,D,Z),startOffset:q})}return X}function M7($,Y,X){let[Z,J]=Y;if(!Z)return{match:null,repair:null,status:"stale"};if(J&&Z.score===J.score)return{match:null,repair:null,status:"ambiguous"};let K=p2(Z.container,Z.startOffset,Z.endOffset),Q=x2(Z.container,Z.startOffset,Z.endOffset),M=X??(Q===$.quote&&(K.prefix??"")===($.anchor.prefix??"")&&(K.suffix??"")===($.anchor.suffix??"")?"matched":"repaired");return{match:yK(Z.container,Z.startOffset,Z.endOffset),repair:{anchor:K,quote:Q},status:M}}function yK($,Y,X){return{containerId:$.id,containerKind:$.containerKind,containerOrdinal:$.containerOrdinal,endOffset:X,startOffset:Y}}function TK($,Y,X){let Z=0;if(G8(Y.text,$.anchor.prefix,X))Z+=K7;if(V8(Y.text,$.anchor.suffix,X+$.quote.length))Z+=K7;return Z}function N8($,Y,X,Z,J){let K=0;if(G8(Y.text,$.anchor.prefix,X))K+=Q7;if(V8(Y.text,$.anchor.suffix,Z))K+=Q7;if(K+=Math.max(0,FK-Math.abs(J-(Z-X))),$.quote.length>0){let Q=Y.text.slice(X,Z);if(Q.length>0)K+=jK($.quote,Q),K+=wK($.quote,Q)}return K}function jK($,Y){let X=0;while(X<$.length&&X<Y.length&&$[X]===Y[X])X+=1;return X}function wK($,Y){let X=0;while(X<$.length&&X<Y.length&&$[$.length-1-X]===Y[Y.length-1-X])X+=1;return X}function A8($){if(!$||typeof $!=="object"||Array.isArray($))return null;let Y=$,X=BK(Y.anchor),Z=typeof Y.quote==="string"?Y.quote:null,J=Array.isArray(Y.comments)?Y.comments.flatMap((K)=>{let Q=OK(K);return Q?[Q]:[]}):[];if(!X||!Z||J.length===0)return null;return{quote:Z,anchor:X,comments:J,resolvedAt:typeof Y.resolvedAt==="string"?Y.resolvedAt:void 0}}function OK($){if(!$||typeof $!=="object"||Array.isArray($))return null;let Y=$;if(typeof Y.body!=="string"||typeof Y.updatedAt!=="string")return null;return{body:Y.body,updatedAt:Y.updatedAt}}function BK($){if(!$||typeof $!=="object"||Array.isArray($))return null;let{kind:Y,prefix:X,suffix:Z}=$;if("kind"in $&&!q8(Y)||"prefix"in $&&typeof X!=="string"||"suffix"in $&&typeof Z!=="string")return null;return{kind:q8(Y)?D8(Y):void 0,prefix:typeof X==="string"?X:void 0,suffix:typeof Z==="string"?Z:void 0}}function _8($){let Y=$.createdAt??new Date().toISOString();return{comments:[q7({body:$.body,updatedAt:Y})],quote:$.quote,anchor:$.anchor}}function H8($,Y){let X=q7(Y);return{...$,comments:[...$.comments,X]}}function z8($,Y,X,Z=new Date().toISOString()){let J=X.trim();if(J.length===0)return $;let K=!1,Q=$.comments.map((M,D)=>{if(D!==Y||M.body===J)return M;return K=!0,{...M,body:J,updatedAt:Z}});if(!K)return $;return{...$,comments:Q}}function F8($,Y){let X=$.comments.filter((Z,J)=>J!==Y);if(X.length===$.comments.length)return $;if(X.length===0)return null;return{...$,comments:X}}function E8($,Y,X=new Date().toISOString()){if(U1($)===Y)return $;return{...$,resolvedAt:Y?X:void 0}}function U1($){return $.resolvedAt!=null}function W8($){return $.filter((Y)=>U1(Y)).length}function P8($){if($.comments.length===0)return null;return $.comments.reduce((Y,X)=>X.updatedAt>Y?X.updatedAt:Y,$.comments[0].updatedAt)}function q7($){let Y=$.updatedAt??new Date().toISOString();return{body:$.body,updatedAt:Y}}function D7($,Y,X,Z,J){let K=Z-X,Q=J-K;if(Z<=$)return{end:Y+Q,start:$+Q};if(X>=Y)return{end:Y,start:$};let M=Math.max(0,Math.min(X,Y)-$),D=Math.max(0,Y-Math.max(Z,$)),q=$<X?$:X;return{end:q+M+J+D,start:q}}function T8($,Y,X){let Z=X.trim();if(Z.length===0||Y.startOffset===Y.endOffset)return null;let J=$.regionIndex.get(Y.regionId)??null,K=J?y8($,J):null;if(!K)return null;return _8({anchor:p2(K,Y.startOffset,Y.endOffset),body:Z,quote:x2(K,Y.startOffset,Y.endOffset)})}function S0($){let Y="documentIndex"in $?$.documentIndex:$,X=T5(Y),Z=Y.document.comments,J=[...Z],K=[];for(let[Q,M]of Z.entries()){let D=l2(M,Y.document);if(!D.match)continue;let U=X.findBySemanticMatch(D.match.containerId,D.match.containerOrdinal)?.runtimeContainer??null;if(!U)continue;if(D.repair)J[Q]={...M,anchor:D.repair.anchor,quote:D.repair.quote};K.push({endOffset:D.match.endOffset,resolution:D,regionId:U.id,resolved:M.resolvedAt!=null,startOffset:D.match.startOffset,threadIndex:Q})}return{liveRanges:K,threads:J}}function j8($,Y,X,Z,J,K){if($.document.comments.length===0)return Y.document.comments;let Q=$.commentContainerIndex.get(X.semanticRegionId)??[],M=new Set(Q);if(Q.length===0)return Y.document.comments;let D=S0($),q=new Map(D.liveRanges.map((N)=>[N.threadIndex,N])),U=y8($,X),V=Q2(Y,X.path),G=V?y8(Y,V):null;if(!U||!G)return Y.document.comments;return Y.document.comments.map((N,A)=>{if(!M.has(A))return N;let _=q.get(A),z=_?.resolution.match??null;if(!_||!z||z.containerId!==U.id)return N;let F=D7(z.startOffset,z.endOffset,Z,J,K.length);return{...N,anchor:p2(G,F.start,F.end),quote:x2(G,F.start,F.end)}})}function y8($,Y){let X=CK($,Y);if(!X)return null;return{containerKind:X,containerOrdinal:-1,id:Y.semanticRegionId,text:Y.text}}function CK($,Y){if($.tableCellIndex.has(Y.id))return"tableCell";return J7(Y.blockType)}function j5($,Y){if(Y.length===0)return[];let X=T5($),Z=X.list();return Y.map((J)=>({...J,cursorPoint:LK(J,Z,X),viewport:null}))}function LK($,Y,X){if(!$.cursor)return null;let Z=RK(Y,$.cursor),J=bK(Z,$.cursor);if(J.length!==1)return null;let K=J[0],Q=X.resolveRuntimeContainer(K.container.id);if(!Q)return null;return{offset:Math.max(0,Math.min(K.offset,Q.text.length)),regionId:Q.id}}function RK($,Y){return Y.kind?$.filter((X)=>X.containerKind===Y.kind):$}function bK($,Y){if(Y.prefix&&Y.suffix)return SK($,Y.prefix,Y.suffix);if(Y.prefix)return U7($,Y.prefix,"after");if(Y.suffix)return U7($,Y.suffix,"before");return[]}function U7($,Y,X){let Z=[];for(let J of $)for(let K of a0(J.text,Y))Z.push({container:J,offset:X==="after"?K+Y.length:K});return Z}function SK($,Y,X){let Z=[];for(let J of $)for(let K of K2(J.text,Y,X))Z.push({container:J,offset:K.startOffset});return Z}var vK=48;function d2($,Y,X){let Z="documentIndex"in $?$.documentIndex:$;if(X.length===0)return[];return X.map((J)=>({...J,viewport:fK(Z,Y,J)}))}function fK($,Y,X){if(!X.cursorPoint)return{status:"unresolved"};let Z=v0(Y.layout,$,X.cursorPoint),J=Z?{bottom:Z.top+Z.height,top:Z.top}:Y.estimateRegionBounds(X.cursorPoint.regionId);if(!J)return{status:"unresolved"};return{scrollTop:hK(Y,J),status:mK(Y,J)}}function mK($,Y){let X=$.viewport.top,Z=X+$.viewport.height;if(Y.bottom<X)return"above";if(Y.top>Z)return"below";return"visible"}function hK($,Y){let X=Math.max(0,$.totalHeight-$.viewport.height),Z=Y.top-Math.min(vK,$.viewport.height/4);return Math.max(0,Math.min(X,Z))}function T5($){let Y=y5($.document),X=new Map(Y.map((J)=>[J.id,J])),Z=new Map($.regions.map((J)=>[J.semanticRegionId,J]));return{findBySemanticMatch(J,K){let Q=X.get(J)??Y[K]??null;if(!Q)return null;return{runtimeContainer:Z.get(Q.id)??null,semanticContainer:Q}},list(J){return J?Y.filter((K)=>K.containerKind===J):Y},resolveRuntimeContainer(J){return Z.get(J)??null}}}var c2="",G7=1e6;function a2($,Y,X){return`${$}:${Y}:${X}`}function M2($){let Y=XQ($),X=O8(Y.blocks.map((Z,J)=>s2(Z,J)));return B8(Y,X)}function s2($,Y){let X=[],Z=[],J=[],K=new Set,Q=0;function M(q,U,V,G,N=null){if(Z.length>0)J.push(`
|
|
10
|
+
`),Q+=1;let A=V.map((F)=>F.text).join(""),_=Q,z=_+A.length;J.push(A),Q=z;for(let F of V)if(F.image)K.add(F.image.url);Z.push({blockId:q.id,blockType:q.type,end:z,id:`${q.id}:${U}`,path:U,rootIndex:Y,inlines:V,semanticRegionId:G,start:_,tableCellPosition:N,text:A})}function D(q,U,V,G){let N={childBlockIds:[],depth:V,end:Q,id:q.id,parentBlockId:G,path:U,regionIds:[],rootIndex:Y,start:Q,type:q.type};switch(X.push(N),q.type){case"blockquote":case"listItem":for(let[A,_]of q.children.entries())N.childBlockIds.push(_.id),D(_,`${U}.children.${A}`,V+1,q.id);break;case"code":{M(q,`${U}.source`,[{end:q.source.length,id:`${q.id}:code`,image:null,inlineCode:!1,kind:"text",link:null,marks:[],originalType:null,start:0,text:q.source}],q.id),N.regionIds.push(Z.at(-1).id);break}case"heading":case"paragraph":M(q,`${U}.children`,w8(q.children),q.id),N.regionIds.push(Z.at(-1).id);break;case"list":for(let[A,_]of q.items.entries())N.childBlockIds.push(_.id),D(_,`${U}.children.${A}`,V+1,q.id);break;case"table":for(let[A,_]of q.rows.entries())for(let[z,F]of _.cells.entries())M(q,`${U}.rows.${A}.cells.${z}`,w8(F.children),F.id,{cellIndex:z,rowIndex:A}),N.regionIds.push(Z.at(-1).id);break;case"divider":break;case"directive":break;case"raw":M(q,`${U}.source`,[{end:q.source.length,id:`${q.id}:raw`,image:null,inlineCode:!1,kind:"raw",link:null,marks:[],originalType:q.originalType,start:0,text:q.source}],q.id),N.regionIds.push(Z.at(-1).id);break}N.end=Q}return D($,`root.${Y}`,0,null),{blockRange:{end:X.length,start:0},blocks:X,end:Q,imageUrls:K,length:Q,regionRange:Z.length>0?{end:Z.length,start:0}:void 0,regions:Z,rootIndex:Y,start:0,text:J.join("")}}function O8($,Y=null){let X=[],Z=0,J=0,K=0,Q=!1;for(let[M,D]of $.entries()){if(D.regions.length>0&&Q)K+=1;let q={...D,blockRange:{end:Z+D.blocks.length,start:Z},end:K+D.length,regionRange:D.regions.length>0?{end:J+D.regions.length,start:J}:void 0,start:K},U=Y?.[M];if(X.push(uK(U,D,q)?U:V7(D,q)),Z=q.blockRange.end,J=q.regionRange?.end??J,D.regions.length>0)K=q.end,Q=!0}return X}function q2($,Y,X,Z){let J=Y.blocks.length-($.roots.length-Z);if(J<0)throw Error("Editor model splice received an invalid replacement count.");if(X===$.roots.length&&J===1){let D=Y.blocks[X];if(D)return kK($,Y,D)}let K=J===Z,Q=[...$.roots.slice(0,X),...Y.blocks.slice(X,X+J).map((D,q)=>s2(D,X+q)),...K?$.roots.slice(X+Z):Y.blocks.slice(X+J).map((D,q)=>s2(D,X+J+q))],M=O8(Q,$.roots);return B8(Y,M,$)}function kK($,Y,X){let Z=$.roots.length,J=s2(X,Z),K=$.roots.some((U)=>U.regions.length>0),Q=J.regions.length>0&&K?$.length+1:$.length,M=V7(J,{...J,blockRange:{end:$.blocks.length+J.blocks.length,start:$.blocks.length},end:Q+J.length,regionRange:J.regions.length>0?{end:$.regions.length+J.regions.length,start:$.regions.length}:void 0,start:Q}),D=[...$.blocks,...M.blocks],q=[...$.regions,...M.regions];return{blockIndex:lK($.blockIndex,M.blocks),blocks:D,commentContainerIndex:Y.comments===$.document.comments?$.commentContainerIndex:N7(Y),document:Y,engine:"canvas",imageUrls:eK($.imageUrls,M.imageUrls),length:M.end,listItemMarkers:Y.blocks===$.document.blocks?$.listItemMarkers:iK($.listItemMarkers,X),regionIndex:dK($.regionIndex,M.regions),regionOrderIndex:cK($.regionOrderIndex,M.regions,$.regions.length),regionPathIndex:aK($.regionPathIndex,M.regions),regions:q,roots:[...$.roots,M],tableCellIndex:rK($.tableCellIndex,M.regions),tableCellRegionIndex:sK($.tableCellRegionIndex,M.regions),text:oK($.text,M)}}function w5($,Y){if(Y.blocks!==$.document.blocks)throw Error("Editor model document replacement requires preserving root blocks.");return B8(Y,$.roots,$)}function O5($,Y,X){let Z=$.blockIndex.get(Y);if(!Z)return null;return e9($.document,Y,X,Z.rootIndex)}function B8($,Y,X=null){let Z=Y.flatMap((U)=>U.blocks),J=Y.flatMap((U)=>U.regions),{regionIndex:K,regionOrderIndex:Q,regionPathIndex:M,tableCellIndex:D,tableCellRegionIndex:q}=xK(J);return{blockIndex:pK(Z),blocks:Z,commentContainerIndex:$.comments===X?.document.comments?X.commentContainerIndex:N7($),document:$,engine:"canvas",imageUrls:tK(Y,X?.imageUrls),length:Y.at(-1)?.end??0,listItemMarkers:$.blocks===X?.document.blocks?X.listItemMarkers:YQ($.blocks),regionIndex:K,regionOrderIndex:Q,regionPathIndex:M,regions:J,roots:Y,tableCellIndex:D,tableCellRegionIndex:q,text:nK(Y)}}function V7($,Y){let X=Y.start-$.start;return{...Y,blocks:X===0?$.blocks:gK($.blocks,X),regions:X===0?$.regions:IK($.regions,X)}}function uK($,Y,X){return Boolean($&&Y===$&&$.start===X.start&&$.end===X.end&&$.blockRange.start===X.blockRange.start&&$.blockRange.end===X.blockRange.end&&$.regionRange?.start===X.regionRange?.start&&$.regionRange?.end===X.regionRange?.end)}function gK($,Y){return $.map((X)=>({...X,end:X.end+Y,start:X.start+Y}))}function IK($,Y){return $.map((X)=>({...X,end:X.end+Y,start:X.start+Y}))}function pK($){let Y=new Map;for(let X of $)Y.set(X.id,X);return Y}function xK($){let Y=new Map,X=new Map,Z=new Map,J=new Map,K=new Map;for(let[Q,M]of $.entries()){if(Y.set(M.id,M),X.set(M.id,Q),Z.set(M.path,M),!M.tableCellPosition)continue;J.set(M.id,M.tableCellPosition),K.set(a2(M.blockId,M.tableCellPosition.rowIndex,M.tableCellPosition.cellIndex),M.id)}return{regionIndex:Y,regionOrderIndex:X,regionPathIndex:Z,tableCellIndex:J,tableCellRegionIndex:K}}function lK($,Y){let X=new Map($);for(let Z of Y)X.set(Z.id,Z);return X}function dK($,Y){let X=new Map($);for(let Z of Y)X.set(Z.id,Z);return X}function cK($,Y,X){let Z=new Map($);for(let[J,K]of Y.entries())Z.set(K.id,X+J);return Z}function aK($,Y){let X=new Map($);for(let Z of Y)X.set(Z.path,Z);return X}function rK($,Y){let X=new Map($);for(let Z of Y)if(Z.tableCellPosition)X.set(Z.id,Z.tableCellPosition);return X}function sK($,Y){let X=new Map($);for(let Z of Y){if(!Z.tableCellPosition)continue;X.set(a2(Z.blockId,Z.tableCellPosition.rowIndex,Z.tableCellPosition.cellIndex),Z.id)}return X}function iK($,Y){let X=new Map($);return r2(X,[Y]),X}function oK($,Y){if(Y.regions.length===0)return $;return $.length>0?`${$}
|
|
11
|
+
${Y.text}`:Y.text}function nK($){return $.filter((Y)=>Y.regions.length>0).map((Y)=>Y.text).join(`
|
|
12
|
+
`)}function tK($,Y){let X=new Set;for(let Z of $)for(let J of Z.imageUrls)X.add(J);return Y&&$Q(Y,X)?Y:X}function eK($,Y){if(Y.size===0)return $;let X=null;for(let Z of Y){if($.has(Z))continue;X??=new Set($),X.add(Z)}return X??$}function $Q($,Y){if($.size!==Y.size)return!1;for(let X of $)if(!Y.has(X))return!1;return!0}function N7($){let Y=new Map;for(let[X,Z]of $.comments.entries()){let J=l2(Z,$).match?.containerId??null;if(!J)continue;let K=Y.get(J)??[];K.push(X),Y.set(J,K)}return Y}function YQ($){let Y=new Map;return r2(Y,$),Y}function r2($,Y,X=null){for(let Z of Y){if(Z.type==="list"){for(let[J,K]of Z.items.entries())r2($,[K],{index:J,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(X?.ordered)$.set(Z.id,{kind:"ordered",label:`${(X.start??1)+X.index}.`});else $.set(Z.id,{kind:"bullet",label:"•"});r2($,Z.children,X)}if(Z.type==="blockquote")r2($,Z.children,X)}}function XQ($){if($.blocks.length>0)return $;return J2([i({text:""})],$.comments,$.frontMatter)}function w8($,Y=null){let X=[],Z=0,J=(K)=>{let Q=Z,M=Q+K.text.length;X.push({...K,end:M,start:Q}),Z=M};for(let K of $)switch(K.type){case"lineBreak":J({id:K.id,image:null,inlineCode:!1,kind:"lineBreak",link:Y,marks:[],originalType:null,text:`
|
|
13
|
+
`});break;case"image":J({id:K.id,image:{alt:K.alt,title:K.title,url:K.url,width:K.width},inlineCode:!1,kind:"image",link:Y,marks:[],originalType:null,text:ZQ(K.alt)});break;case"code":J({id:K.id,image:null,inlineCode:!0,kind:"code",link:Y,marks:[],originalType:null,text:K.code});break;case"link":for(let Q of w8(K.children,{title:K.title,url:K.url}))J(Q);break;case"text":J({id:K.id,image:null,inlineCode:!1,kind:"text",link:Y,marks:K.marks,originalType:null,text:K.text});break;case"raw":J({id:K.id,image:null,inlineCode:!1,kind:"raw",link:Y,marks:[],originalType:K.originalType,text:K.source});break}return X}function ZQ($){return c2}function W0($){switch($.type){case"lineBreak":return 1;case"image":return c2.length;case"code":return $.code.length;case"link":return X0($.children).length;case"text":return $.text.length;case"raw":return $.source.length}}function i2($,Y,X,Z,J){let K=[],Q=0,M=!1;for(let[D,q]of $.entries()){let U=`${Z}.${D}`,V=W0(q),G=Q,N=G+V;if(Q=N,X<=G||Y>=N){K.push(q);continue}if(!M)K.push(...JQ(q,Math.max(0,Y-G),U)),K.push(...J),M=!0;K.push(...KQ(q,Math.min(V,X-G),U))}if(!M)K.push(...J);return Z0(K)}function JQ($,Y,X){if(Y<=0)return[];return C8($,0,Y,`${X}.before`)}function KQ($,Y,X){let Z=W0($);if(Y>=Z)return[];return C8($,Y,Z,`${X}.after`)}function C8($,Y,X,Z){if(Y>=X)return[];switch($.type){case"text":return Z0([b1($.text.slice(Y,X),$.marks,Z)].filter(Boolean));case"code":return[R8($.code.slice(Y,X),Z)];case"link":{let J=Z0(QQ($.children,Y,X,`${Z}.children`));return J.length>0?[{...$,children:J}]:[]}default:return[]}}function L8($,Y,X){let Z=0,J="";for(let K of $){let Q=W0(K),M=Z,D=M+Q;if(Z=D,X<=M||Y>=D)continue;J+=MQ(K,Math.max(0,Y-M),Math.min(Q,X-M))}return J}function b1($,Y,X){if($.length===0)return null;return q1({marks:Y,path:X,text:$})}function R8($,Y){return e1({code:$,path:Y})}function QQ($,Y,X,Z){let J=[],K=0;for(let[Q,M]of $.entries()){let D=W0(M),q=K,U=q+D;if(K=U,X<=q||Y>=U)continue;J.push(...C8(M,Math.max(0,Y-q),Math.min(D,X-q),`${Z}.${Q}`))}return J}function MQ($,Y,X){if(Y>=X)return"";switch($.type){case"lineBreak":return`
|
|
14
|
+
`.slice(Y,X);case"image":return c2.slice(Y,X);case"code":return $.code.slice(Y,X);case"link":return L8($.children,Y,X);case"text":return $.text.slice(Y,X);case"raw":return $.source.slice(Y,X)}}function b8($,Y,X,Z){let J=qQ($.children,Y,X,Z);if(J===null)return null;let K=Z0(A7($.children,Y,X,Z,J,`${$.path}.children`));return K.length>0?S1($,K,Y,X):null}function S8($,Y,X){let Z=0,J=null,K=(Q)=>{for(let M of Q){let D=W0(M),q=Z,U=q+D;if(Z=U,X<=q||Y>=U)continue;if(M.type==="text"){let V=Math.max(Y,q);if(Math.min(X,U)>V)J=J===null?new Set(M.marks):new Set(M.marks.filter((N)=>J?.has(N)));continue}if(M.type==="link"){let V=Z;Z=q,K(M.children),Z=V}}};return K($.children),J?[...J]:[]}function qQ($,Y,X,Z){let J=0,K=!1,Q=!0,M=(D)=>{for(let q of D){let U=W0(q),V=J,G=V+U;if(J=G,X<=V||Y>=G)continue;if(q.type==="text"){let N=Math.max(Y,V);if(Math.min(X,G)>N)K=!0,Q&&=q.marks.includes(Z);continue}if(q.type==="link"){let N=J;J=V,M(q.children),J=N}}};return M($),K?Q:null}function A7($,Y,X,Z,J,K){let Q=[],M=0;for(let[D,q]of $.entries()){let U=M,V=W0(q),G=U+V,N=`${K}.${D}`;if(M=G,X<=U||Y>=G){Q.push(q);continue}if(q.type==="text"){Q.push(...DQ(q,Math.max(0,Y-U),Math.min(V,X-U),Z,J,N));continue}if(q.type==="link"){let A=Z0(A7(q.children,Math.max(0,Y-U),Math.min(V,X-U),Z,J,`${N}.children`));if(A.length>0)Q.push({...q,children:A});continue}Q.push(q)}return Q}function DQ($,Y,X,Z,J,K){let Q=$.text.slice(0,Y),M=$.text.slice(Y,X),D=$.text.slice(X),q=J?$.marks.filter((U)=>U!==Z):UQ($.marks,Z);return[b1(Q,$.marks,`${K}.before`),b1(M,q,`${K}.selected`),b1(D,$.marks,`${K}.after`)].filter(Boolean)}function UQ($,Y){return $.includes(Y)?$:[...$,Y].sort()}function v8($,Y,X){let Z=GQ($.children,Y,X,`${$.path}.children`);return Z.length>0?S1($,Z,Y,X):null}function GQ($,Y,X,Z){let J=_7($,Y,X);if(J){let Q=b1(J.code,[],`${Z}.selected`);return i2($,Y,X,Z,Q?[Q]:[])}let K=L8($,Y,X);if(K.length===0)return $;return i2($,Y,X,Z,[R8(K,`${Z}.selected`)])}function _7($,Y,X){let Z=0;for(let J of $){let K=W0(J),Q=Z,M=Q+K;if(Z=M,Y===Q&&X===M&&J.type==="code")return J;if(J.type==="link"){let D=_7(J.children,Math.max(0,Y-Q),Math.min(K,X-Q));if(D)return D}}return null}function B5($,Y,X,Z,J){return C5($,Y,X,Z,(K,Q,M)=>H7(K,Q,M,J))}function H7($,Y,X,Z){let J=Z0(VQ($.children,Y,X,Z,`${$.path}.children`)??[]);return J.length>0?S1($,J,Y,X):null}function VQ($,Y,X,Z,J){let K=[],Q=0,M=!1;for(let[D,q]of $.entries()){let U=`${J}.${D}`,V=W0(q),G=Q,N=G+V;if(Q=N,!M&&q.type==="link"&&Y===G&&X===N){if(Z===null)K.push(...q.children);else K.push($2({children:q.children,path:U,title:q.title,url:Z}));M=!0;continue}K.push(q)}return M?K:null}function D2($,Y){let X=$.regionIndex.get(Y);if(!X)return null;let Z=c0($.document.blocks,X.blockId);if(!Z)return null;return f8(Z,X.path,X.semanticRegionId)}function NQ($,Y,X,Z,J){if(X>=Z)return null;let K=D2($,Y);return K?J(K,X,Z):null}function C5($,Y,X,Z,J){let K=NQ($,Y,X,Z,J);return K?{kind:"replace-block",block:K.block,blockId:K.blockId,selection:K.selection}:null}function f8($,Y,X){if($.type==="heading"||$.type==="paragraph")return{block:$,children:$.children,kind:"inlineBlock",path:Y.replace(/\.children$/,"")};if($.type!=="table")return null;let Z=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(Y);if(!Z)return null;for(let J of $.rows)for(let K of J.cells)if(K.id===X)return{block:$,blockPath:Z[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:K,children:K.children,kind:"tableCell",path:Z[1]};return null}function m8($,Y,X){let Z=W7($,Y);if(!Z)return null;return{kind:"replace-block",...o2(Z.inlineRegion,Z.startOffset,Z.endOffset,X)}}function F7($,Y,X){let Z=W7($,Y);if(!Z)return null;return{kind:"replace-block",...E7(Z.inlineRegion,Z.startOffset,Z.endOffset,X)}}function E7($,Y,X,Z){let J=`${$.path}.children`,K=i2($.children,Y,X,J,Z),Q=Z.reduce((D,q)=>D+W0(q),0),M=Y+Q;return S1($,K,M,M)}function o2($,Y,X,Z){let J=Z(`${$.path}.children.selected`);return E7($,Y,X,[J])}function W7($,Y){let X=D2($,Y.focus.regionId);if(!X)return null;return{inlineRegion:X,startOffset:Math.min(Y.anchor.offset,Y.focus.offset),endOffset:Math.max(Y.anchor.offset,Y.focus.offset)}}function S1($,Y,X,Z){switch($.kind){case"inlineBlock":return{block:O0($.block,Y),blockId:$.block.id,selection:z7(`${$.path}.children`,X,Z)};case"tableCell":{let J=D1({children:Y,path:$.path}),K=$.block.rows.map((Q)=>({...Q,cells:Q.cells.map((M)=>M.id===$.cell.id?J:M)}));return{block:B0($.block,K),blockId:$.block.id,selection:z7($.path,X,Z)}}}}function z7($,Y,X){return{endOffset:X,kind:"region-range-path",path:$,startOffset:Y}}function H0($,Y,X=0){return{childIndices:Y,kind:"descendant-primary-region",offset:X,rootIndex:$}}function $0($,Y=0){return{kind:"root-primary-region",offset:Y,rootIndex:$}}function h8($,Y=0){return{kind:"region",offset:Y,regionId:$}}function v1($,Y,X,Z=0){return{cellIndex:X,kind:"table-cell",offset:Z,rootIndex:$,rowIndex:Y}}function P0($,Y){return $.regionIndex.get(Y)??null}function Q2($,Y){return $.regionPathIndex.get(Y)??null}function V2($,Y,X,Z){let J=$.tableCellRegionIndex.get(a2(Y,X,Z));return J?$.regionIndex.get(J)??null:null}function f1($,Y){let X=$.regionOrderIndex.get(Y);if(X===void 0||X===0)return null;return $.regions[X-1]??null}function n2($,Y){let X=$.regionOrderIndex.get(Y);if(X===void 0)return null;return $.regions[X+1]??null}function r0($){return $.regionIds.length===0&&!G1($)}function G1($){return $.type==="blockquote"||$.type==="list"||$.type==="listItem"}function k8($,Y){return y7($.blocks,Y,-1)}function t2($,Y){return y7($.blocks,Y,1)}function y7($,Y,X){let Z=$.findIndex((J)=>J.id===Y);if(Z===-1)return null;for(let J=Z+X;J>=0&&J<$.length;J+=X){let K=$[J];if(G1(K))continue;return K}return null}function u8($,Y){return $.roots[Y]?.regions[0]??null}function AQ($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function Y0($,Y){let X="documentIndex"in $?$.documentIndex:$,Z="documentIndex"in $?$.selection:Y,J=AQ(Z),K=P7(X,Z.anchor),Q=P7(X,Z.focus);if(K<=Q)return{collapsed:J,end:Z.focus,start:Z.anchor};return{collapsed:J,end:Z.anchor,start:Z.focus}}function e2($,Y){if(!Y)return null;if(Y.kind==="root-primary-region"){let Z=$.document.blocks[Y.rootIndex],J=Z?L5($,Z):null;return J?U2(J.id,G2(J.text,Y.offset)):null}if(Y.kind==="descendant-primary-region"){let Z=$.document.blocks[Y.rootIndex],J=Z?_Q(Z,Y.childIndices):null,K=J?L5($,J):null;return K?U2(K.id,G2(K.text,Y.offset)):null}if(Y.kind==="region"){let Z=P0($,Y.regionId);return Z?U2(Z.id,G2(Z.text,Y.offset)):null}if(Y.kind==="block-primary-region"){let Z=c0($.document,Y.blockId),J=Z?L5($,Z):null;return J?U2(J.id,G2(J.text,Y.offset)):null}if(Y.kind==="table-cell"){let Z=$.document.blocks[Y.rootIndex];if(!Z||Z.type!=="table")return null;let J=V2($,Z.id,Y.rowIndex,Y.cellIndex);return J?U2(J.id,G2(J.text,Y.offset)):null}let X=Q2($,Y.path);if(!X)return null;if(Y.kind==="region-path")return U2(X.id,G2(X.text,Y.offset));return{anchor:{regionId:X.id,offset:Math.max(0,Math.min(Y.startOffset,X.text.length))},focus:{regionId:X.id,offset:Math.max(0,Math.min(Y.endOffset,X.text.length))}}}function U2($,Y){let X={offset:Y,regionId:$};return{anchor:X,focus:X}}function P7($,Y){let X=$.regionOrderIndex.get(Y.regionId);if(X===void 0)throw Error(`Unknown canvas region: ${Y.regionId}`);return X*G7+Y.offset}function G2($,Y){return Y==="end"?$.length:Math.max(0,Math.min(Y,$.length))}function _Q($,Y){let X=$;for(let Z of Y){if(!X)return null;let J=_0(X);if(!J)return null;X=J[Z]??null}return X}function L5($,Y){let X=$.blockIndex.get(Y.id);if(!X)return null;let Z=X.regionIds[0];if(Z)return $.regionIndex.get(Z)??null;let J=_0(Y);if(!J)return null;for(let K of J){let Q=L5($,K);if(Q)return Q}return null}function $4($){let Y=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,X=Y?$.documentIndex.blockIndex.get(Y.blockId)??null:null,Z=T7($);return{block:X?{blockId:X.id,depth:X.depth,nodeType:X.type,text:Y?.text??""}:null,span:Z?.link?{kind:"link",url:Z.link.url}:Z&&Z.marks.length>0?{kind:"marks",marks:Z.marks}:{kind:"none"}}}function R5($){let Y=T7($);return Y?.kind==="image"?Y:null}function b5($){let Y=Y0($.documentIndex,$.selection);if(Y.start.regionId!==Y.end.regionId||Y.start.offset===Y.end.offset)return[];let X=$.documentIndex.regionIndex.get(Y.start.regionId);if(!X)return[];let Z=c0($.documentIndex.document.blocks,X.blockId);if(!Z)return[];let J=f8(Z,X.path,X.semanticRegionId);return J?S8(J,Y.start.offset,Y.end.offset):[]}function T7($){let Y=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null;if(!Y)return null;let X=$.selection.anchor.offset;return Y.inlines.find((Z)=>X>Z.start&&X<Z.end)??Y.inlines.find((Z)=>Z.end===X)??Y.inlines.find((Z)=>Z.start===X)??null}var v5="rgba(0, 0, 0, 0)";function N2($,Y,X){let Z=j7($),J=j7(Y);return`rgba(${I8(S5(Z[0],J[0],X))}, ${I8(S5(Z[1],J[1],X))}, ${I8(S5(Z[2],J[2],X))}, ${S5(Z[3],J[3],X)})`}var g8=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function j7($){let Y=g8.get($);if(Y)return Y;let X=HQ($)??zQ($)??FQ($)??g8.get("rgba(0, 0, 0, 0)");return g8.set($,X),X}function HQ($){let Y=$.trim();if(!Y.startsWith("#"))return null;let X=Y.slice(1);if(X.length===3)return[Number.parseInt(`${X[0]}${X[0]}`,16),Number.parseInt(`${X[1]}${X[1]}`,16),Number.parseInt(`${X[2]}${X[2]}`,16),1];if(X.length===6)return[Number.parseInt(X.slice(0,2),16),Number.parseInt(X.slice(2,4),16),Number.parseInt(X.slice(4,6),16),1];return null}function zQ($){let Y=/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!Y)return null;return[Number(Y[1]),Number(Y[2]),Number(Y[3]),1]}function FQ($){let Y=/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i.exec($.trim());if(!Y)return null;return[Number(Y[1]),Number(Y[2]),Number(Y[3]),Number(Y[4])]}function S5($,Y,X){return $+(Y-$)*X}function I8($){return Math.round($)}var EQ=300,WQ=180,PQ=1000,yQ=500,TQ=140,jQ=0.1,wQ=0.9,OQ=2,BQ=2;function Y4($){switch($.kind){case"active-block-flash":return EQ;case"deleted-text-fade":return WQ;case"inserted-text-highlight":return PQ;case"list-marker-pop":return yQ;case"punctuation-pulse":return TQ}}function p8($,Y){let X=Y??LQ();return $.animations.some((Z)=>X-Z.startedAt<Y4(Z))}function w7($,Y){return x8($,Y,"inserted-text-highlight",(X)=>X.regionPath)}function O7($,Y){return h7($,Y,"active-block-flash",(X)=>X.blockPath)}function B7($,Y){return x8($,Y,"deleted-text-fade",(X)=>X.regionPath)}function C7($,Y){return x8($,Y,"punctuation-pulse",(X)=>X.regionPath)}function L7($,Y){return h7($,Y,"list-marker-pop",(X)=>X.blockPath)}function R7($,Y,X){let Z=new Set([$,Y]);for(let J of X){if(J.endOffset<=$||J.startOffset>=Y)continue;Z.add(Math.max($,J.startOffset)),Z.add(Math.min(Y,J.endOffset))}return[...Z].sort((J,K)=>J-K)}function b7($,Y,X){return $.find((Z)=>Z.startOffset<X&&Z.endOffset>Y)??null}function S7($,Y,X){if(!Y)return $;return N2(X.insertHighlightText,$,Y.progress)}function v7($,Y){return N2($,v5,Y.progress)}function f5($,Y){return N2($,v5,Y.progress)}function f7($,Y){return N2(Y.insertHighlightText,v5,$.progress)}function m7($){let Y=Math.min(1,$.progress*OQ);return jQ+wQ*CQ(Y)}function X4($,Y,X){let Z=Math.max(0,Y.progress*BQ-1);return N2(X.insertHighlightText,$,Z)}function x8($,Y,X,Z){let J=new Map;for(let K of $.animations){if(K.kind!==X)continue;let Q=Y4(K),M=Y-K.startedAt;if(M>=Q)continue;let D={...K,progress:Math.max(0,Math.min(1,M/Q))},q=Z(K),U=J.get(q);if(U)U.push(D);else J.set(q,[D])}return J}function h7($,Y,X,Z){let J=new Map;for(let K of $.animations){if(K.kind!==X)continue;let Q=Y4(K),M=Y-K.startedAt;if(M>=Q)continue;J.set(Z(K),{...K,progress:Math.max(0,Math.min(1,M/Q))})}return J}function CQ($){return 1-(1-$)*(1-$)*(1-$)}function LQ(){return typeof performance<"u"?performance.now():Date.now()}function m5($,Y,X=m1()){if(Y<=0)return $;let Z=k5($);if(!Z)return $;let J=$.selection.focus.offset,K=Math.max(0,J-Y);if(J<=K)return $;return Z4($,{endOffset:J,kind:"inserted-text-highlight",regionPath:Z.path,startOffset:K,startedAt:X})}function k7($,Y,X,Z){let J=k5($);if(!J)return Y;let K=J.text.slice(X,Z);if(K.length===0)return Y;if(!J.inlines.some((M)=>M.start<=X&&M.end>=Z&&M.kind==="text"&&M.link===null&&M.marks.length===0))return Y;return Z4(Y,{kind:"deleted-text-fade",regionPath:J.path,startOffset:X,startedAt:m1(),text:K})}function u7($,Y=m1()){let X=k5($),Z=$.selection.focus.offset-1;if(!X||Z<0||X.text[Z]!==".")return $;return Z4($,{kind:"punctuation-pulse",offset:Z,regionPath:X.path,startedAt:Y})}function g7($,Y,X=m1()){return Z4($,{blockPath:Y,kind:"list-marker-pop",startedAt:X})}function I7($,Y,X=m1()){return Z4($,{blockPath:Y,kind:"active-block-flash",startedAt:X})}function l8($,Y){return $.filter((X)=>X.startedAt+Y4(X)>Y)}function m1(){return typeof performance<"u"?performance.now():Date.now()}function h5($,Y){let X=Math.max(-1/0,...$.animations.map((Z)=>Z.startedAt));return Y.animations.some((Z)=>Z.startedAt>X)}function p7($){let Y=k5($);return(Y?$.documentIndex.blockIndex.get(Y.blockId)??null:null)?.path??""}function k5($){return $.documentIndex.regionIndex.get($.selection.focus.regionId)??null}function Z4($,Y){let X=l8($.animations,Y.startedAt);return{...$,animations:[...X,Y]}}function A2($,Y,X,Z){return c8(_2($.inlines,Y,X,Z))}function _2($,Y,X,Z){let K=RQ($,Y,X,{didInsert:!1,generatedRunCount:0,replacementText:Z});return mQ(hQ(K))}function c8($){let Y=[];for(let X=0;X<$.length;X+=1){let Z=$[X];if(Z.link){let K=[],Q=Z.link;while(X<$.length&&a8($[X].link,Q)){let M=l7($[X]);if(M)K.push(M);X+=1}if(X-=1,K.length>0)Y.push($2({children:Z0(K),title:Q.title,url:Q.url}));continue}let J=l7(Z);if(J)Y.push(J)}return Z0(Y)}function RQ($,Y,X,Z){let J=[];for(let[K,Q]of $.entries()){if(!Z.didInsert&&Y===X&&Y===Q.start)d8(J,Z,x7($[K-1]??null,Q));if(X<=Q.start||Y>=Q.end){J.push(u5(Q));continue}let M=Math.max(0,Y-Q.start),D=Math.min(Q.text.length,X-Q.start),q=!Z.didInsert&&Z.replacementText.length>0?Z.replacementText:"",U=bQ(Q,M,D,q,Z);if(M!==D||q.length>0)Z.didInsert=!0;J.push(...U)}if(!Z.didInsert)d8(J,Z,x7($.at(-1)??null,null));return J}function bQ($,Y,X,Z,J){switch($.kind){case"text":case"code":case"raw":return SQ($,Y,X,Z);case"lineBreak":return vQ($,Y,X,Z,J);case"image":return fQ($,Y,X,Z)}}function SQ($,Y,X,Z){let J=$.text.slice(0,Y)+Z+$.text.slice(X);return J.length>0?[{...u5($),text:J}]:[]}function vQ($,Y,X,Z,J){if(Y===X)return[u5($)];let K=[];if(Z.length>0)d8(K,J,$.link);return K}function fQ($,Y,X,Z){if(Y===0&&X===$.text.length)return Z.length>0?[d7(Z,$.link,0)]:[];return[u5($)]}function d8($,Y,X){if(Y.replacementText.length===0){Y.didInsert=!0;return}$.push(d7(Y.replacementText,X,Y.generatedRunCount)),Y.generatedRunCount+=1,Y.didInsert=!0}function d7($,Y,X){return{id:`generated:${X}`,image:null,inlineCode:!1,kind:"text",link:Y,marks:[],originalType:null,text:$}}function x7($,Y){return $?.link&&Y?.link&&a8($.link,Y.link)?$.link:null}function u5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function mQ($){let Y=[],X=0;for(let Z of $){let J=X,K=J+Z.text.length;Y.push({...Z,end:K,start:J}),X=K}return Y}function hQ($){let Y=[];for(let X of $){let Z=Y.at(-1);if(Z&&kQ(Z,X)){Y[Y.length-1]={...Z,text:Z.text+X.text};continue}Y.push(X)}return Y}function kQ($,Y){return $.kind===Y.kind&&$.inlineCode===Y.inlineCode&&a8($.link,Y.link)&&gQ($.image,Y.image)&&$.originalType===Y.originalType&&$.marks.join(",")===Y.marks.join(",")}function l7($){switch($.kind){case"lineBreak":return l0();case"image":return $.image?uQ($.image):null;case"code":return e1({code:$.text});case"text":return $.text.length>0?q1({marks:$.marks,text:$.text}):null;case"raw":return z5({originalType:$.originalType??"raw",source:$.text})}}function uQ($){return j1({alt:$.alt,title:$.title,url:$.url,width:$.width})}function a8($,Y){return $?.url===Y?.url&&$?.title===Y?.title}function gQ($,Y){return $?.url===Y?.url&&$?.title===Y?.title&&$?.alt===Y?.alt&&$?.width===Y?.width}function s7($,Y,X){let Z=[],J=0,K={childIndices:[],offset:0},Q="",M=$!==null;if($)Z.push($),K=c7($);let D=0;if($&&Y.length>0){let q=Y[0];if(g5($)&&q.type==="paragraph"){let U=r8($,$.children,q.children);Z[Z.length-1]=U,K={childIndices:[],offset:U.plainText.length},D=1,Q=q.plainText}else if(a7($,q)){let U=r7($,q);Z[Z.length-1]=U,K=i7(U),D=1}}for(let q=D;q<Y.length;q+=1){let U=Y[q];Z.push(U),J=Z.length-1,K=c7(U)}if(X){let q=Z.length-1,U=Z[q]??null,V=D>=Y.length&&$!==null,G=null;if(U){if(!V&&U.type==="paragraph"&&g5(X)){if(G=r8(X,U.children,X.children),$===null&&Y.length===1)M=!0,Q=U.plainText}else if(V&&g5(U)&&g5(X))G=r8(U,U.children,X.children);else if(a7(U,X))G=r7(U,X),K={childIndices:[_0(U).length-1],offset:"end"}}else if($===null&&Y.length===0)M=!0;if(G)Z[q]=G;else Z.push(X)}return{blocks:Z,caretLocalIndex:J,caretChildIndices:K.childIndices,caretOffset:K.offset,startRegionInsertedText:Q,startRegionPreservedAtRoot0:M}}function J4($,Y,X){if($.type==="table")return null;if($.id===Y.blockId)return IQ($,Y,X);return o7($,(Z)=>xQ(Z,Y,X))}function K4($,Y,X){if($.type==="table")return null;if($.id===Y.blockId)return pQ($,Y,X);return o7($,(Z)=>lQ(Z,Y,X))}function h1($,Y){if($.id===Y.blockId)return!0;let X=_0($);return X!==null&&X.some((Z)=>h1(Z,Y))}function c7($){return _0($)?i7($):{childIndices:[],offset:$.plainText.length}}function i7($){return{childIndices:[_0($).length-1],offset:"end"}}function r8($,Y,X){return O0($,Z0([...Y,...X]))}function g5($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function a7($,Y){return $.type===Y.type&&_0($)!==null}function r7($,Y){let X=_0($),Z=_0(Y);return R1($,[...X,...Z])}function IQ($,Y,X){if(X===0)return null;switch($.type){case"heading":case"paragraph":return O0($,A2(Y,X,Y.text.length,""));case"code":return g2($,Y.text.slice(0,X));case"raw":return I2($,Y.text.slice(0,X));default:return null}}function pQ($,Y,X){if(X===Y.text.length)return null;switch($.type){case"heading":case"paragraph":return O0($,A2(Y,0,X,""));case"code":return g2($,Y.text.slice(X));case"raw":return I2($,Y.text.slice(X));default:return null}}function o7($,Y){let X=_0($);return X?R1($,Y(X)):null}function xQ($,Y,X){let Z=$.findIndex((Q)=>h1(Q,Y));if(Z===-1)return[];let J=$.slice(0,Z),K=J4($[Z],Y,X);return K?[...J,K]:J}function lQ($,Y,X){let Z=$.findIndex((Q)=>h1(Q,Y));if(Z===-1)return[];let J=$.slice(Z+1),K=K4($[Z],Y,X);return K?[K,...J]:J}function t7($,Y,X){let Z=Y0($,Y);if(Z.start.regionId===Z.end.regionId)return dQ($,Z,X);let J=X.length>0?[i({text:X})]:[];return s8($,Y,J)}function s8($,Y,X){let Z=Y0($,Y),J=P0($,Z.start.regionId),K=P0($,Z.end.regionId);if(!J||!K)throw Error("Unknown selection endpoints.");let Q=$.document.blocks[J.rootIndex],M=$.document.blocks[K.rootIndex];if(!Q||!M)throw Error("Unknown root blocks for selection.");let D=J4(Q,J,Z.start.offset),q=K4(M,K,Z.end.offset),U=s7(D,X,q),V=U.blocks.length>0?U.blocks:[i({text:""})],G=J.rootIndex,N=K.rootIndex-J.rootIndex+1,A=L1($.document,G,N,V),_=q2($,A,G,N),z=J===K?Z.end.offset:J.text.length;return{documentIndex:U.startRegionPreservedAtRoot0?e7($,_,J,Z.start.offset,z,U.startRegionInsertedText):_,selection:H0(G+U.caretLocalIndex,U.caretChildIndices,U.caretOffset)}}function dQ($,Y,X){let Z=P0($,Y.start.regionId);if(!Z)throw Error(`Unknown region: ${Y.start.regionId}`);let J=O5($,Z.blockId,(D)=>cQ(D,Z,Y.start.offset,Y.end.offset,X));if(!J)throw Error(`Failed to replace block for region: ${Z.id}`);let K=q2($,J,Z.rootIndex,1),Q=e7($,K,Z,Y.start.offset,Y.end.offset,X),M=Q2(Q,Z.path);if(!M)throw Error(`Failed to remap region after replacement: ${Z.path}`);return{documentIndex:Q,selection:h8(M.id,Y.start.offset+X.length)}}function cQ($,Y,X,Z,J){switch($.type){case"heading":case"paragraph":return O0($,A2(Y,X,Z,J));case"code":return g2($,n7(Y,X,Z,J));case"table":return aQ($,Y,X,Z,J);case"raw":return I2($,n7(Y,X,Z,J));default:throw Error(`Region text replacement is not supported for block type: ${$.type}`)}}function aQ($,Y,X,Z,J){let K=Y.tableCellPosition?.rowIndex,Q=Y.tableCellPosition?.cellIndex;if(K===void 0||Q===void 0)throw Error(`Unable to resolve table cell position for region: ${Y.id}`);let M=A2(Y,X,Z,J),D=$.rows.map((q,U)=>{if(U!==K)return q;let V=q.cells.map((G,N)=>N===Q?D1({children:M}):G);return{...q,cells:V}});return B0($,D)}function n7($,Y,X,Z){return _2($.inlines,Y,X,Z).map((J)=>J.text).join("")}function e7($,Y,X,Z,J,K){if($.document.comments.length===0)return Y;let Q=j8($,Y,X,Z,J,K);return Q===Y.document.comments?Y:w5(Y,{...Y.document,comments:Q})}function M4($){let Y=M2($),X=Z$(Y);return{animations:[],documentIndex:Y,future:[],history:[],selection:{anchor:X,focus:X}}}function s0($){let Y=S0($.documentIndex);return J2(X7($.documentIndex.document.blocks),Y.threads,$.documentIndex.document.frontMatter)}function f0($,Y){if(!Y)return null;switch(Y.kind){case"keep-state":return $;case"set-selection":return K0($,Y.selection);case"replace-block":{let X=O5($.documentIndex,Y.blockId,()=>Y.block);return X?Q4($,M2(X),Y.selection??null):null}case"splice-blocks":{let X=L1($.documentIndex.document,Y.rootIndex,Y.count??1,Y.blocks);return Q4($,M2(X),Y.selection??null)}case"splice-text":{let X=t7($.documentIndex,Y.selection,Y.text);return Q4($,X.documentIndex,X.selection)}case"splice-fragment":{let X=s8($.documentIndex,Y.selection,Y.blocks);return Q4($,X.documentIndex,X.selection)}case"splice-comments":{let X=t9($.documentIndex.document,Y.index,Y.count,Y.threads);return Q4($,w5($.documentIndex,X),null)}}}function Q4($,Y,X){let Z=rQ($,Y),J=e2(Z.documentIndex,X)??$.selection,K=J$($,Z,J);return K0(Z,J,K)}function K0($,Y,X){let Z="regionId"in Y?{anchor:I5($.documentIndex,Y),focus:I5($.documentIndex,Y)}:{anchor:I5($.documentIndex,Y.anchor),focus:I5($.documentIndex,Y.focus)},J={...$,selection:Z};return X??J$($,J)?I7(J,p7(J)):J}function y0($,Y,X,Z){let J={regionId:Y,offset:X};return K0($,Z?{anchor:$.selection.anchor,focus:J}:J)}function rQ($,Y){let X=Z$(Y);return{animations:l8($.animations,m1()),documentIndex:Y,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:{anchor:X,focus:X}}}function i8($){let Y=$.history.at(-1);if(!Y)return $;return X$(Y,{future:[Y$($),...$.future],history:$.history.slice(0,-1)})}function o8($){let Y=$.future[0];if(!Y)return $;return X$(Y,{future:$.future.slice(1),history:[...$.history,Y$($)]})}function Y$($){return{document:$.documentIndex.document,selection:$.selection}}function X$($,Y){return{animations:[],documentIndex:M2($.document),future:Y.future,history:Y.history,selection:$.selection}}function Z$($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function I5($,Y){let X=P0($,Y.regionId);if(!X)return Y;return{regionId:X.id,offset:Math.max(0,Math.min(Y.offset,X.text.length))}}function J$($,Y,X){let Z=$$($.documentIndex,$.selection),J=$$(Y.documentIndex,X??Y.selection);return J!==null&&J!==Z}function $$($,Y){let X=$.regionIndex.get(Y.focus.regionId),Z=X?$.blockIndex.get(X.blockId)??null:null;if(!X||!Z?.path)return null;return Z.type==="table"?`cell:${X.path}`:`block:${Z.path}`}function U4($,Y){let X=$.regionIndex.get(Y.anchor.regionId);if(!X)return{kind:"unsupported"};if(X.blockType==="code"){let M=$.blockIndex.get(X.blockId);return M?{kind:"code",region:X,rootIndex:M.rootIndex,...D4($,X,Y)}:{kind:"unsupported"}}let Z=t8($,X.id);if(Z)return{kind:"tableCell",...Z,...D4($,X,Y)};let J=z2($,Y);if(J)return{kind:"listItem",...J};let K=sQ($,Y);if(K)return{kind:"blockquoteTextBlock",...K};let Q=H2($,Y);if(Q)return{kind:"rootTextBlock",...Q};return{kind:"unsupported"}}function K$($,Y,X){let Z=U4($,Y),J=Z.kind==="unsupported"?!1:X==="backward"?Z.atStart:Z.atEnd;switch(Z.kind){case"rootTextBlock":return{...Z,kind:"rootTextBlock",direction:X,atBoundary:J,previousRoot:$.document.blocks[Z.rootIndex-1]??null,nextRoot:$.document.blocks[Z.rootIndex+1]??null};case"listItem":return{...Z,kind:"listItem",direction:X,atBoundary:J,previousItem:Z.list.items[Z.itemIndex-1]??null,nextItem:Z.list.items[Z.itemIndex+1]??null,previousRoot:$.document.blocks[Z.rootIndex-1]??null,nextRoot:$.document.blocks[Z.rootIndex+1]??null};case"blockquoteTextBlock":return{...Z,kind:"blockquoteTextBlock",direction:X,atBoundary:J,previousSibling:Z.quote.children[Z.childIndex-1]??null,nextSibling:Z.quote.children[Z.childIndex+1]??null};default:return{kind:"unsupported",direction:X,atBoundary:!1}}}function n8($,Y,X){let Z=Y?$.blockIndex.get(Y)??null:null;while(Z){if(Z.type===X)return Z;let J=Z.parentBlockId;Z=J?$.blockIndex.get(J)??null:null}return null}function V1($){let Y=$.split("."),X=[];for(let Z=0;Z<Y.length-1;Z+=1)if(Y[Z]==="children"){let J=Number(Y[Z+1]);if(Number.isInteger(J))X.push(J)}return X}function H2($,Y){let X=$.regionIndex.get(Y.anchor.regionId);if(!X)return null;let Z=$.blockIndex.get(X.blockId);if(!Z)return null;let J=Z.rootIndex,K=$.document.blocks[J];if(!K||K.type!=="heading"&&K.type!=="paragraph")return null;return{...D4($,X,Y),block:K,region:X,rootIndex:J}}function sQ($,Y){let X=$.regionIndex.get(Y.anchor.regionId);if(!X)return null;let Z=$.blockIndex.get(X.blockId),J=n8($,Z?.id??null,"blockquote");if(!Z||!J||Z.parentBlockId!==J.id)return null;let K=J.rootIndex,Q=$.document.blocks[K];if(!Q||Q.type!=="blockquote")return null;let M=Q.children.findIndex((q)=>q.id===Z.id),D=Q.children[M];if(!D||D.type!=="heading"&&D.type!=="paragraph")return null;return{...D4($,X,Y),block:D,blockChildIndices:V1(Z.path),childIndex:M,region:X,quote:Q,rootIndex:K}}function q4($,Y){return c0($.document.blocks,Y)}function z2($,Y){let X=$.regionIndex.get(Y.anchor.regionId);if(!X)return null;let Z=$.blockIndex.get(X.blockId),J=n8($,Z?.id??null,"listItem"),K=n8($,Z?.id??null,"list");if(!Z||!J||!K)return null;let Q=q4($,K.id);if(!Q||Q.type!=="list")return null;let M=Q.items.findIndex((A)=>A.id===J.id),D=Q.items[M];if(!D)return null;let q=K.parentBlockId?$.blockIndex.get(K.parentBlockId)??null:null,U=q?.parentBlockId?$.blockIndex.get(q.parentBlockId)??null:null,V=q?.type==="listItem"?q4($,q.id):null,G=U?.type==="list"?q4($,U.id):null,N=G?.type==="list"&&V?G.items.findIndex((A)=>A.id===V.id):-1;return{...D4($,X,Y),region:X,item:D,itemChildIndices:V1(J.path),itemIndex:M,list:Q,listChildIndices:V1(K.path),parentItem:V?.type==="listItem"?V:null,parentItemChildIndices:q?.type==="listItem"?V1(q.path):null,parentItemIndex:N>=0?N:null,parentList:G?.type==="list"?G:null,parentListChildIndices:U?.type==="list"?V1(U.path):null,rootIndex:K.rootIndex}}function t8($,Y){let X=$.regionIndex.get(Y);if(!X)return null;let Z=$.tableCellIndex.get(X.id),J=$.blockIndex.get(X.blockId),K=J?.type==="table"?$.document.blocks[J.rootIndex]:null;if(!Z||!J||!K||K.type!=="table")return null;return{cellIndex:Z.cellIndex,region:X,rootIndex:J.rootIndex,rowIndex:Z.rowIndex,table:K}}function D4($,Y,X){let Z=Y0($,X),J=Z.start.regionId===Y.id?Z.start.offset:X.anchor.offset;return{atEnd:J===Y.text.length,atStart:J===0,empty:Y.text.length===0,offset:J}}function G4($,Y,X){return w1({checked:Y,children:[i({text:$})],spread:X})}function Q$($,Y){let X=$.children[0];if(!X||X.type!=="paragraph")return null;return d0($,[i({text:Y}),...$.children.slice(1)])}function M$($,Y){return Y.reduce((X,Z)=>`${X}.children.${Z}`,`root.${$}`)}function q$($,Y){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let X=P0($.documentIndex,$.selection.focus.regionId);if(!X)return null;if(Y==="forward"&&$.selection.focus.offset>=X.text.length)return null;let Z=Y==="backward"?iQ(X.text,$.selection.focus.offset):$.selection.focus.offset,J=Y==="backward"?$.selection.focus.offset:oQ(X.text,$.selection.focus.offset);if(Z===J)return null;return{kind:"splice-text",selection:{anchor:{regionId:X.id,offset:Z},focus:{regionId:X.id,offset:J}},text:""}}function iQ($,Y){let X=Array.from($.slice(0,Y));if(X.length===0)return 0;return Y-X.at(-1).length}function oQ($,Y){let X=Array.from($.slice(Y))[0];return X?Y+X.length:$.length}function D$($,Y,X){if(Y.anchor.regionId!==Y.focus.regionId)return null;let Z=$.regionIndex.get(Y.anchor.regionId);if(!Z)return null;let J=tQ($,Y,Z);if(!J)return null;let{start:K,end:Q}=nQ($,Y);return eQ(Z,X,K,Q,J)}function nQ($,Y){if(Y.anchor.offset===Y.focus.offset)return{start:Y.anchor.offset,end:Y.anchor.offset};let X=Y0($,Y);return{start:X.start.offset,end:X.end.offset}}function tQ($,Y,X){switch(X.blockType){case"heading":{let Z=H2($,Y);return Z?.block.type==="heading"?{kind:"heading",rootIndex:Z.rootIndex}:null}case"paragraph":{let Z=z2($,Y);if(Z)return{kind:"list-item",item:Z};let J=H2($,Y);return J?.block.type==="paragraph"?{kind:"root-paragraph",rootIndex:J.rootIndex}:null}default:return null}}function eQ($,Y,X,Z,J){if(J.kind==="root-paragraph"&&!$M($,Y,Z))return null;let K=$.text.slice(0,X)+Y+$.text.slice(Z);switch(J.kind){case"root-paragraph":return e8(YM,K,J);case"heading":return e8(XM,K,J);case"list-item":return e8(ZM,K,J.item)}}function $M($,Y,X){let Z=X<$.text.length?$.text:Y;return Z.length>0&&/\s/.test(Z[Z.length-1])}function e8($,Y,X){for(let{pattern:Z,apply:J}of $){let K=Z.exec(Y);if(K)return J(K,X)}return null}var YM=[{pattern:F2(/\[[ xX]?\]/,{allowIndent:!0}),apply:($,{rootIndex:Y})=>$3(Y,{checked:$[1].toLowerCase().includes("x"),ordered:!1,start:null})},{pattern:F2(/[-+*]/,{allowIndent:!0}),apply:($,{rootIndex:Y})=>$3(Y,{checked:null,ordered:!1,start:null})},{pattern:F2(/\d+\./,{allowIndent:!0}),apply:($,{rootIndex:Y})=>$3(Y,{checked:null,ordered:!0,start:Number($[1].slice(0,-1))})},{pattern:F2(/#{1,6}/,{allowIndent:!1}),apply:($,{rootIndex:Y})=>({kind:"splice-blocks",blocks:[t1({depth:$[1].length,text:""})],rootIndex:Y,selection:$0(Y)})},{pattern:F2(/>/,{allowIndent:!1}),apply:($,{rootIndex:Y})=>({kind:"splice-blocks",blocks:[R0({children:[i({text:""})]})],rootIndex:Y,selection:H0(Y,[0])})},{pattern:F2(/---/,{allowIndent:!1}),apply:($,{rootIndex:Y})=>({kind:"splice-blocks",blocks:[F5(),i({text:""})],rootIndex:Y,selection:$0(Y+1)})}],XM=[{pattern:p5(/#{1,6}/),apply:($,{rootIndex:Y})=>({kind:"splice-blocks",blocks:[t1({depth:$[1].length,text:$[2]})],rootIndex:Y,selection:$0(Y)})}],ZM=[{pattern:p5(/\d+\./),apply:($,Y)=>Y3($,Y,{ordered:!0,start:1,checked:Y.item.checked})},{pattern:p5(/\[[ xX]?\]/),apply:($,Y)=>Y3($,Y,{ordered:!1,start:null,checked:$[1].toLowerCase().includes("x")})},{pattern:p5(/[-+*]/),apply:($,Y)=>Y3($,Y,{ordered:!1,start:null,checked:null})}];function F2($,Y){let X=Y.allowIndent?"\\s*":"";return new RegExp(`^${X}(${$.source})\\s$`)}function p5($){return new RegExp(`^\\s*(${$.source})\\s(.+)$`)}function $3($,Y){return{kind:"splice-blocks",blocks:[O1({items:[w1({checked:Y.checked,children:[i({text:""})],spread:!1})],ordered:Y.ordered,spread:!1,start:Y.start})],rootIndex:$,selection:H0($,[0,0])}}function Y3($,Y,X){let Z=Q$(Y.item,$[2]);if(!Z)return null;return{kind:"replace-block",block:M0(Y.list,Y.list.items.map((J,K)=>K===Y.itemIndex?{...Z,checked:X.checked}:J),{ordered:X.ordered,start:X.start}),blockId:Y.list.id,selection:H0(Y.rootIndex,[...Y.listChildIndices,Y.itemIndex,0])}}function U$($,Y,X){return D$($,Y,X)??{kind:"splice-text",selection:Y,text:X}}function G$($,Y){let X=$.region.text.length,Z=$.region.text.slice(0,Y),J=$.region.text.slice(Y),K=Y===0&&X>0?$.rootIndex:$.rootIndex+1;return{kind:"splice-blocks",blocks:A$($.block,Z,J,Y,X),rootIndex:$.rootIndex,selection:$0(K)}}function V$($,Y){let X=$.region.text,Z=X.slice(0,Y),J=X.slice(Y),K=A$($.block,Z,J,Y,X.length),Q=Y===0?$.blockChildIndices:[...$.blockChildIndices.slice(0,-1),$.blockChildIndices.at(-1)+1];return{kind:"splice-blocks",blocks:[R0({children:[...$.quote.children.slice(0,$.childIndex),...K,...$.quote.children.slice($.childIndex+1)]})],rootIndex:$.rootIndex,selection:H0($.rootIndex,Q)}}function N$($,Y){if(Y!==0||$.region.text.length!==0||$.block.type!=="paragraph")return null;let X=$.quote.children.slice(0,$.childIndex),Z=$.quote.children.slice($.childIndex+1),J=[];if(X.length>0)J.push(R0({children:X}));if(J.push(i({text:""})),Z.length>0)J.push(R0({children:Z}));return{kind:"splice-blocks",blocks:J,rootIndex:$.rootIndex,selection:$0($.rootIndex+(X.length>0?1:0))}}function X3($,Y,X){if($.block.type!=="heading")return null;let Z=Math.max(1,Math.min(6,$.block.depth+Y));if(Z===$.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[t1({depth:Z,text:$.block.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex,X)}}function A$($,Y,X,Z,J){if(Z===0)return[i({text:""}),$];if(Z===J)return[$,i({text:""})];return[$.type==="heading"?t1({depth:$.depth,text:Y}):i({text:Y}),i({text:X})]}function V4($,Y,X,Z=0){return H0($,[...Y,X,0],Z)}function Z3($,Y){let X=$.region.text,Z=$.item,J=typeof Z.checked==="boolean"?!1:Z.checked;if(Y===0){let q=G4("",J,Z.spread);return{kind:"replace-block",block:M0($.list,[...$.list.items.slice(0,$.itemIndex),q,Z,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:x5(q,$.rootIndex,[...$.listChildIndices,$.itemIndex]),selection:V4($.rootIndex,$.listChildIndices,$.itemIndex)}}if(Y===X.length){let q=G4("",J,Z.spread);return{kind:"replace-block",block:M0($.list,[...$.list.items.slice(0,$.itemIndex+1),q,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:x5(q,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:V4($.rootIndex,$.listChildIndices,$.itemIndex+1)}}let K=X.slice(0,Y),Q=X.slice(Y),M=G4(Q,J,Z.spread),D=d0(Z,[i({text:K})]);return{kind:"replace-block",block:M0($.list,[...$.list.items.slice(0,$.itemIndex),D,M,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:x5(M,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:V4($.rootIndex,$.listChildIndices,$.itemIndex+1)}}function _$($,Y){if(Y!==0||$.region.text.length!==0)return Z3($,Y);if($.parentItem&&$.parentItemIndex!==null&&$.parentItemChildIndices&&$.parentList&&$.parentListChildIndices)return JM($);let X=$.list.items.slice(0,$.itemIndex),Z=$.list.items.slice($.itemIndex+1),J=[];if(X.length>0)J.push(M0($.list,X));if(J.push(i({text:""})),Z.length>0)J.push(M0($.list,Z));return{kind:"splice-blocks",blocks:J,rootIndex:$.rootIndex,selection:$0($.rootIndex+(X.length>0?1:0))}}function H$($){if($.itemIndex===0)return null;let Y=$.list.items[$.itemIndex-1];if(!Y)return null;let X=KM(Y,$.item,$);return{kind:"replace-block",block:M0($.list,$.list.items.flatMap((Z,J)=>{if(J===$.itemIndex-1)return[X.item];if(J===$.itemIndex)return[];return[Z]})),blockId:$.list.id,selection:H0($.rootIndex,X.regionChildIndices)}}function z$($){return F$($,()=>({insertedItem:$.item}))}function J3($,Y){let X=$.itemIndex+Y;if(X<0||X>=$.list.items.length)return null;let Z=[...$.list.items],[J]=Z.splice($.itemIndex,1);if(!J)return null;return Z.splice(X,0,J),{kind:"replace-block",block:M0($.list,Z),blockId:$.list.id,selection:V4($.rootIndex,$.listChildIndices,X)}}function JM($){return F$($,(Y)=>{let X=typeof Y.checked==="boolean"?!1:Y.checked;return{insertedItem:G4("",X,Y.spread),trackInsertedPath:!0}})}function F$($,Y){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let X=$.list.items.filter((D,q)=>q!==$.itemIndex),Z=$.parentItem.children.flatMap((D)=>{if(D.type!=="list"||D.id!==$.list.id)return[D];if(X.length===0)return[];return[M0($.list,X)]}),J=d0($.parentItem,Z),{insertedItem:K,trackInsertedPath:Q=!1}=Y($.parentItem),M=Q?x5(K,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]):void 0;return{kind:"replace-block",block:M0($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),J,K,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:M,selection:V4($.rootIndex,$.parentListChildIndices,$.parentItemIndex+1)}}function x5($,Y,X){return typeof $.checked==="boolean"?void 0:M$(Y,X)}function KM($,Y,X){let Z=$.children.findIndex((K)=>K.type==="list"&&K.ordered===X.list.ordered&&K.start===X.list.start);if(Z>=0){let K=$.children[Z];if(!K||K.type!=="list")return{item:$,regionChildIndices:[...X.listChildIndices,X.itemIndex-1,0]};return{item:d0($,$.children.map((Q,M)=>M===Z?M0(K,[...K.items,Y]):Q)),regionChildIndices:[...X.listChildIndices,X.itemIndex-1,Z,K.items.length,0]}}let J=O1({items:[Y],ordered:X.list.ordered,spread:X.list.spread,start:X.list.start});return{item:d0($,[...$.children,J]),regionChildIndices:[...X.listChildIndices,X.itemIndex-1,$.children.length,0,0]}}function E$($,Y,X){let Z=H2($,Y),J=Math.max(2,X);if(!Z||Z.block.type!=="paragraph"||Z.block.plainText.length>0||Y.anchor.regionId!==Y.focus.regionId||Y.anchor.offset!==0||Y.focus.offset!==0)return null;return{kind:"splice-blocks",blocks:[B1({rows:Array.from({length:2},()=>Q3(J))})],rootIndex:Z.rootIndex,selection:v1(Z.rootIndex,0,0)}}function K3($,Y,X,Z){let J=Z<0?DM(X.table,X.rowIndex,X.cellIndex):UM(X.table,X.rowIndex,X.cellIndex);if(!J)return Z>0&&GM(X.table,X.rowIndex,X.cellIndex)?QM(X):{kind:"keep-state"};let K=X.table.rows[J.rowIndex]?.cells[J.cellIndex];if(!K)return{kind:"keep-state"};return{kind:"set-selection",selection:qM($,Y,X.table,J.rowIndex,J.cellIndex,Math.min(Y.focus.offset,K.plainText.length))}}function W$($,Y){let X=D2($,Y.focus.regionId);if(!X||X.kind!=="tableCell")return null;let Z=Math.min(Y.anchor.offset,Y.focus.offset),J=Math.max(Y.anchor.offset,Y.focus.offset),K=o2(X,Z,J,(Q)=>l0({path:Q}));return{kind:"replace-block",block:K.block,blockId:K.blockId,selection:K.selection}}function P$($,Y){let X=Y==="left"?$.cellIndex:$.cellIndex+1;return E2($,B1({align:B$($.table.align,X,0,[null]),rows:$.table.rows.map((Z)=>Y2({cells:MM(Z.cells,X,0,[O$()])}))}),v1($.rootIndex,$.rowIndex,X))}function y$($){let Y=Math.max(0,...$.table.rows.map((X)=>X.cells.length));if(Y<=1)return null;return E2($,B1({align:B$($.table.align,$.cellIndex,1,[]),rows:$.table.rows.map((X)=>Y2({cells:X.cells.filter((Z,J)=>J!==$.cellIndex)}))}),v1($.rootIndex,$.rowIndex,Math.min($.cellIndex,Y-2)))}function T$($,Y){let X=Y==="above"?$.rowIndex:$.rowIndex+1,Z=Math.max(1,...$.table.rows.map((J)=>J.cells.length));return E2($,B0($.table,[...$.table.rows.slice(0,X),Q3(Z),...$.table.rows.slice(X)]),v1($.rootIndex,X,Math.min($.cellIndex,Z-1)))}function j$($){if($.table.rows.length<=1)return null;let Y=$.table.rows.filter((J,K)=>K!==$.rowIndex),X=Math.min($.rowIndex,Y.length-1),Z=Y[X]?.cells.length??1;return E2($,B0($.table,Y),v1($.rootIndex,X,Math.min($.cellIndex,Z-1)))}function w$($){return E2($,i({text:""}),$0($.rootIndex))}function Q3($){return Y2({cells:Array.from({length:$},()=>O$())})}function O$(){return D1({children:[]})}function QM($){let Y=$.table.rows.length,X=Math.max(1,...$.table.rows.map((Z)=>Z.cells.length));return E2($,B0($.table,[...$.table.rows,Q3(X)]),v1($.rootIndex,Y,0))}function E2($,Y,X){return{kind:"replace-block",block:Y,blockId:$.table.id,selection:X}}function MM($,Y,X,Z){return[...$.slice(0,Y),...Z,...$.slice(Y+X)]}function B$($,Y,X,Z){return[...$.slice(0,Y),...Z,...$.slice(Y+X)]}function qM($,Y,X,Z,J,K){let Q=V2($,X.id,Z,J);if(!Q)return Y;return{anchor:{regionId:Q.id,offset:K},focus:{regionId:Q.id,offset:K}}}function DM($,Y,X){if(X>0)return{cellIndex:X-1,rowIndex:Y};if(Y>0){let Z=$.rows[Y-1];if(!Z||Z.cells.length===0)return null;return{cellIndex:Z.cells.length-1,rowIndex:Y-1}}return null}function UM($,Y,X){let Z=$.rows[Y];if(!Z)return null;if(X+1<Z.cells.length)return{cellIndex:X+1,rowIndex:Y};let J=$.rows[Y+1];if(!J||J.cells.length===0)return null;return{cellIndex:0,rowIndex:Y+1}}function GM($,Y,X){let Z=$.rows[Y];return Boolean(Z&&Y===$.rows.length-1&&X===Z.cells.length-1)}function C$($,Y,X){switch(X.kind){case"code":return{kind:"splice-text",selection:Y,text:`
|
|
15
|
+
`};case"tableCell":return W$($,Y);case"listItem":return _$(X,X.offset)??Z3(X,X.offset);case"blockquoteTextBlock":return N$(X,X.offset)??V$(X,X.offset);case"rootTextBlock":return G$(X,X.offset);case"unsupported":return null}}function R$($,Y){let X=Y0($,Y);if(X.collapsed)return null;let Z=P0($,X.start.regionId),J=P0($,X.end.regionId);if(!Z||!J)return null;let K=$.document.blocks[Z.rootIndex],Q=$.document.blocks[J.rootIndex];if(!K||!Q)return null;if(Z===J)return{kind:"single-region",normalized:X,region:Z,root:K,wholeRegion:X.start.offset===0&&X.end.offset===Z.text.length};return{kind:"multi-region",normalized:X,startRegion:Z,endRegion:J,sameRoot:Z.rootIndex===J.rootIndex,startRoot:K,endRoot:Q}}function l5($,Y){let X=Y0($,Y),Z=P0($,X.start.regionId),J=P0($,X.end.regionId);if(!Z||!J)return null;let K=L$(Z)||L$(J);return{normalized:X,sameRegion:Z===J,startRegion:Z,endRegion:J,structuralBlocked:K,prefersVerbatimFallback:Z.blockType==="code"||J.blockType==="code"}}function L$($){return $.blockType==="table"||$.blockType==="code"}function M3($,Y){let X=R$($,Y);if(!X)return null;switch(X.kind){case"single-region":if(!X.wholeRegion||X.region.blockType==="table"){let J=NM(X.region,X.normalized.start.offset,X.normalized.end.offset);return VM(J)}let Z=S$(X.root,X.region);return Z?b$([Z]):null;case"multi-region":{let J=X.sameRoot?AM($,X.startRoot,X.startRegion,X.normalized.start.offset,X.endRegion,X.normalized.end.offset):zM($,X.startRegion,X.normalized.start.offset,X.endRegion,X.normalized.end.offset);return J.length>0?b$(J):null}}}function VM($){if($.length===0)return null;if(Q8($))return{kind:"text",text:X0($)};return{kind:"inlines",inlines:$}}function b$($){if(P5($))return{kind:"text",text:$[0].plainText};return{kind:"blocks",blocks:$}}function S$($,Y){if($.id===Y.blockId)return $;let X=_0($);if(!X)return null;let Z=X.find((K)=>h1(K,Y)),J=Z?S$(Z,Y):null;return J?R1($,[J]):null}function NM($,Y,X){let Z=_2($.inlines,X,$.text.length,""),J=_2(Z,0,Y,"");return c8(J)}function AM($,Y,X,Z,J,K){if(Y.type==="table")return HM($,Y,X,Z,J,K);let Q=v$(Y,X,Z,J,K);return Q?[Q]:[]}function _M($,Y,X,Z,J){let K=$.roots[Y.rootIndex],Q=K?.regions[0],M=K?.regions.at(-1);return Y===Q&&Z===M&&X===0&&J===M.text.length}function HM($,Y,X,Z,J,K){if(_M($,X,Z,J,K))return[Y];let Q=X.tableCellPosition?.rowIndex,M=X.tableCellPosition?.cellIndex,D=J.tableCellPosition?.rowIndex,q=J.tableCellPosition?.cellIndex;if(Q===void 0||M===void 0||D===void 0||q===void 0)return[];if(Q!==0||M!==0||Z!==0)return[];let U=Y.rows[D];if(!U)return[];let V=U.cells.length-1;if(q!==V||K!==J.text.length)return[];return[B0(Y,Y.rows.slice(0,D+1))]}function v$($,Y,X,Z,J){let K=_0($);if(!K)return null;let Q=K.findIndex((D)=>h1(D,Y)),M=K.findIndex((D)=>h1(D,Z));if(Q===-1||M===-1)return null;if(Q===M){let D=v$(K[Q],Y,X,Z,J);return D?R1($,[D]):null}return R1($,f$(K,Q,Y,X,M,Z,J))}function zM($,Y,X,Z,J){return f$($.document.blocks,Y.rootIndex,Y,X,Z.rootIndex,Z,J)}function f$($,Y,X,Z,J,K,Q){let M=K4($[Y],X,Z),D=$.slice(Y+1,J),q=J4($[J],K,Q);return[M,...D,q].filter((U)=>U!==null)}function q3($,Y){let X=l5($.documentIndex,$.selection);if(!X)return null;switch(Y.kind){case"text":return Y.text.length>0?f0($,{kind:"splice-text",selection:$.selection,text:Y.text}):null;case"inlines":{if(Y.inlines.length===0)return null;if(X.sameRegion){let Z=F7($.documentIndex,$.selection,Y.inlines);if(Z)return f0($,Z)}if(X.structuralBlocked)return null;return f0($,{kind:"splice-fragment",blocks:[x0({children:Y.inlines})],selection:$.selection})}case"blocks":if(Y.blocks.length===0||X.structuralBlocked)return null;return f0($,{kind:"splice-fragment",blocks:Y.blocks,selection:$.selection})}}function m$($,Y,X,Z){let J=Z==="backward"?k8($,Y.blockId):t2($,Y.blockId);if(J&&r0(J))return FM(Y,J,Z);let K=Z==="backward"?f1($,Y.id):n2($,Y.id);if(!K)return null;if(X)return WM($,Y,K,Z);let Q=Z==="backward"?Y:K,M=Z==="backward"?K:Y;if(!EM(M))return null;return PM($,Q,M)}function FM($,Y,X){if(Y.parentBlockId!==null)return null;let Z=X==="backward"?$.rootIndex-1:$.rootIndex,J=X==="backward"?0:"end";return{kind:"splice-blocks",rootIndex:Y.rootIndex,count:1,blocks:[],selection:c5($,Z,J)}}function EM($){return $.blockType==="paragraph"||$.blockType==="heading"}function WM($,Y,X,Z){let J=$.document.blocks[Y.rootIndex];if(!J)return null;let K=d5(J,Y,X.blockId,void 0),Q=Z==="backward"?X.text.length:0,D=Y.rootIndex===X.rootIndex?TM(K,X.rootIndex,X.blockId,Q):jM(X,Y.rootIndex,K.length,Q);if(!D)return null;return{kind:"splice-blocks",rootIndex:Y.rootIndex,count:1,blocks:K,selection:D}}function PM($,Y,X){let Z=c0($.document,X.blockId),J=c0($.document,Y.blockId);if(!Z||Z.type!=="paragraph"&&Z.type!=="heading")return null;let K=X.text.length,Q=yM(Z,J),M=c5(X,X.rootIndex,K);if(Y.rootIndex===X.rootIndex){let _=$.document.blocks[Y.rootIndex];if(!_)return null;let z=d5(_,Y,X.blockId,Q);return{kind:"splice-blocks",rootIndex:Y.rootIndex,count:1,blocks:z,selection:M}}let D=$.document.blocks[X.rootIndex],q=$.document.blocks[Y.rootIndex];if(!D||!q)return null;let U=d5(D,Y,X.blockId,Q);if(U.length!==1)return null;let V=U[0],G=d5(q,Y,X.blockId,void 0),N=Math.min(X.rootIndex,Y.rootIndex),A=X.rootIndex<Y.rootIndex?[V,...G]:[...G,V];return{kind:"splice-blocks",rootIndex:N,count:2,blocks:A,selection:M}}function c5($,Y,X=0){let Z=V1($.path);if(Z.length===0)return $0(Y,X);return H0(Y,Z,X)}function yM($,Y){let X=Y&&(Y.type==="paragraph"||Y.type==="heading")?Y.children:[];return O0($,Z0([...$.children,...X]))}function TM($,Y,X,Z){for(let J=0;J<$.length;J+=1){let K=$[J],Q=D3(K,X);if(Q){if(Q.length===0)return $0(Y+J,Z);return H0(Y+J,Q,Z)}}return null}function jM($,Y,X,Z){let J=V1($.path),K=X-1,Q=$.rootIndex<Y?$.rootIndex:$.rootIndex+K;if(J.length===0)return $0(Q,Z);return H0(Q,J,Z)}function D3($,Y){if($.id===Y)return[];switch($.type){case"list":for(let X=0;X<$.items.length;X+=1){let Z=D3($.items[X],Y);if(Z)return[X,...Z]}return null;case"listItem":case"blockquote":for(let X=0;X<$.children.length;X+=1){let Z=D3($.children[X],Y);if(Z)return[X,...Z]}return null;default:return null}}function d5($,Y,X,Z){return Z2([$],(J,{parent:K,recurse:Q})=>{if(J.type==="listItem"){let D=J.children[0];if(D&&D.id===Y.blockId)return wM(J)}if(J.id===Y.blockId&&K?.type!=="listItem")return[];if(J.id===X&&Z!==void 0)return Z;let M=Q();if(M.type==="listItem"){let D=M.children[0];if(!D||D.type!=="paragraph"&&D.type!=="heading")return[]}return M})}function wM($){if($.type==="listItem")return $.children.filter((Y)=>Y.type==="list").flatMap((Y)=>Y.items);return[]}function h$($,Y){let X=u8($,Y.rootIndex);if(!X||X.id!==Y.id)return null;let Z=$.document.blocks[Y.rootIndex];if(!Z)return null;let J=OM(Z);if(!J)return null;return{kind:"splice-blocks",rootIndex:Y.rootIndex,count:1,blocks:J,selection:$0(Y.rootIndex)}}function OM($){switch($.type){case"heading":return[x0({children:$.children})];case"blockquote":return[...$.children];case"list":return k$($.items);default:return null}}function k$($){return $.flatMap((Y)=>{let X=[BM(Y)];for(let Z of Y.children)if(Z.type==="list")X.push(...k$(Z.items));return X})}function BM($){let Y=$.children[0];if(Y&&(Y.type==="paragraph"||Y.type==="heading"))return x0({children:Y.children});return i({text:""})}function u$($,Y){if(Y.kind==="unsupported"||!Y.atBoundary)return null;if(Y.direction==="backward"){let X=CM(Y,$);if(X)return X}return m$($,Y.region,Y.empty,Y.direction)}function CM($,Y){let X=h$(Y,$.region);if(X)return X;if($.kind==="rootTextBlock"){let Z=LM($,Y);if(Z)return Z}return null}function LM($,Y){if($.block.type!=="paragraph"||$.block.plainText.length!==0)return null;let X=Y.document.blocks[$.rootIndex-1],Z=Y.document.blocks[$.rootIndex+1];if(!X||X.type!=="list"||!Z||Z.type!=="list"||!RM(X,Z))return null;let J=f1(Y,$.region.id),K=J?c5(J,$.rootIndex-1,"end"):$0($.rootIndex-1,"end");return{kind:"splice-blocks",count:3,blocks:[M0(X,[...X.items,...Z.items])],rootIndex:$.rootIndex-1,selection:K}}function RM($,Y){return $.ordered===Y.ordered&&$.start===Y.start}var N4=Q0(($,Y)=>U$($.documentIndex,$.selection,Y),{animate:($,Y,X,Z)=>{if(X.kind!=="splice-text")return;if(Z===".")return u7(Y);return m5(Y,Z.length)}}),a5=Q0(($,Y)=>C$($.documentIndex,$.selection,Y),{context:U4,animate:($,Y,X)=>{if(X.kind!=="replace-block"||!X.listItemInsertedPath)return;return g7(Y,X.listItemInsertedPath)}}),g$=Q0(($)=>m8($.documentIndex,$.selection,(Y)=>l0({path:Y}))??{kind:"splice-text",selection:$.selection,text:`
|
|
16
|
+
`}),r5=Q0(($,Y)=>({kind:"splice-text",selection:$.selection,text:Y}),{animate:($,Y,X,Z)=>{if(Z.length>0)return m5(Y,Z.length)}}),U3=($)=>r5($,""),G3=GY(VY,($)=>_Y($,"backward"),($)=>NY($,"backward")),V3=GY(VY,($)=>_Y($,"forward"),($)=>NY($,"forward")),N3=($)=>M3($.documentIndex,$.selection);function I$($,Y,X){let Z=q3($,Y);if(Z){let J=bM(Y);return J>0?m5(Z,J):Z}if(Y.kind==="text")return null;return SM($,Y,X)}function bM($){switch($.kind){case"text":return $.text.length;case"inlines":return X0($.inlines).length;case"blocks":return $.blocks.length===1&&$.blocks[0].type==="paragraph"?$.blocks[0].plainText.length:0}}function SM($,Y,X){let Z=l5($.documentIndex,$.selection);if(!Z)return null;let J=Z.prefersVerbatimFallback&&X&&X.length>0?X:Y7(Y);return J.length>0?r5($,J):null}function p$($,Y,X){return y0($,Y,X,!0)}function x$($){let Y=$.documentIndex.regions,X=Y[0],Z=Y.at(-1);if(!X||!Z)return $;return K0($,{anchor:{regionId:X.id,offset:0},focus:{regionId:Z.id,offset:Z.text.length}})}var s5=($)=>t5($,"bold"),i5=($)=>t5($,"italic"),o5=($)=>t5($,"strikethrough"),n5=($)=>t5($,"underline"),l$=($)=>AY($,v8),d$=Q0(($,Y,X,Z,J)=>B5($.documentIndex,Y,X,Z,J)),c$=Q0(($,Y,X,Z)=>B5($.documentIndex,Y,X,Z,null)),a$=Q0(($,Y,X)=>m8($.documentIndex,$.selection,(Z)=>j1({alt:X??null,path:Z,url:Y}))),r$=Q0(($,Y,X,Z)=>{let J=D2($.documentIndex,Y);if(!J)return null;let{image:K}=X,Q=o2(J,X.start,X.end,(M)=>j1({alt:K.alt,path:M,title:K.title,url:K.url,width:Z}));return{kind:"replace-block",block:Q.block,blockId:Q.blockId}}),A3=($)=>i8($),_3=($)=>o8($),s$=Q0(($,Y)=>{switch(Y.kind){case"tableCell":return K3($.documentIndex,$.selection,Y,1);case"rootTextBlock":return X3(Y,1,$.selection.focus.offset);case"listItem":return H$(Y);default:return null}},{context:U4}),i$=Q0(($,Y)=>{switch(Y.kind){case"tableCell":return K3($.documentIndex,$.selection,Y,-1);case"rootTextBlock":return X3(Y,-1,$.selection.focus.offset);case"listItem":return z$(Y);default:return null}},{context:U4}),o$=Q0(($,Y)=>J3(Y,-1),{context:z2}),n$=Q0(($,Y)=>J3(Y,1),{context:z2}),t$=Q0(($,Y)=>{let X=q4($.documentIndex,Y);if(!X||X.type!=="listItem"||typeof X.checked!=="boolean")return null;return{kind:"replace-block",block:{...X,checked:!X.checked},blockId:Y}}),e$=Q0(($,Y)=>E$($.documentIndex,$.selection,Y)),$Y=Q0(($,Y,X)=>P$(Y,X),{context:A4}),YY=Q0(($,Y)=>y$(Y),{context:A4}),XY=Q0(($,Y,X)=>T$(Y,X),{context:A4}),ZY=Q0(($,Y)=>j$(Y),{context:A4}),JY=Q0(($,Y)=>w$(Y),{context:A4}),KY=Q0(($,Y,X)=>{let Z=T8($.documentIndex,Y,X);if(!Z)return null;return{kind:"splice-comments",count:0,index:$.documentIndex.document.comments.length,threads:[Z]}}),QY=($,Y,X)=>_4($,Y,(Z)=>H8(Z,{body:X.trim()})),MY=($,Y,X,Z)=>_4($,Y,(J)=>z8(J,X,Z)),qY=($,Y,X)=>_4($,Y,(Z)=>F8(Z,X)),DY=($,Y)=>_4($,Y,()=>null),UY=($,Y,X)=>_4($,Y,(Z)=>E8(Z,X));function Q0($,Y){return(X,...Z)=>{let J=[];if(Y?.context){let M=Y.context(X.documentIndex,X.selection);if(!M)return null;J.push(M)}let K=$(X,...J,...Z);if(!K)return null;let Q=f0(X,K);return Y?.animate?.(X,Q,K,...Z)??Q}}function GY(...$){return(Y,...X)=>{for(let Z of $){let J=Z(Y,...X);if(J)return J}return null}}function A4($,Y){return t8($,Y.focus.regionId)}function VY($){return vM($)?U3($):null}function NY($,Y){let X=K$($.documentIndex,$.selection,Y);return f0($,u$($.documentIndex,X))}function t5($,Y){return AY($,(X,Z,J)=>b8(X,Z,J,Y))}function AY($,Y){let X=Y0($.documentIndex,$.selection);if(X.start.regionId!==X.end.regionId||X.start.offset===X.end.offset)return null;return f0($,C5($.documentIndex,X.start.regionId,X.start.offset,X.end.offset,Y))}function vM($){let Y=Y0($.documentIndex,$.selection);return Y.start.regionId!==Y.end.regionId||Y.start.offset!==Y.end.offset}function _Y($,Y){let X=q$($,Y);if(!X)return null;let Z=f0($,X);if(!Z)return null;return k7($,Z,X.selection.anchor.offset,X.selection.focus.offset)}function _4($,Y,X){let J=S0($.documentIndex).threads[Y];if(!J)return null;let K=X(J);if(K===J)return null;return f0($,{kind:"splice-comments",count:1,index:Y,threads:K?[K]:[]})}function k1(){return{graphemeWidths:new Map,lineBoundaries:new Map,measuredContainerHeights:new Map,measuredLines:new Map,preparedText:new Map,viewportPlans:new WeakMap}}function HY($,Y,X){return H4($.preparedText,Y,X,256)}function zY($,Y,X){return H4($.measuredLines,Y,X,512)}function FY($,Y,X){return H4($.lineBoundaries,Y,X,1024)}function EY($,Y,X){return H4($.measuredContainerHeights,Y,X,1024)}function WY($,Y){let X=$.graphemeWidths.get(Y);if(X)return X;let Z=new Map;return H4($.graphemeWidths,Y,Z,64),Z}function PY($,Y,X){return $.viewportPlans.get(Y)?.get(X)??null}function yY($,Y,X,Z){let J=$.viewportPlans.get(Y)??new Map;return J.set(X,Z),$.viewportPlans.set(Y,J),Z}function H4($,Y,X,Z){if($.has(Y))$.delete(Y);if($.set(Y,X),$.size>Z){let J=$.keys().next().value;if(J!==void 0)$.delete(J)}return X}var e5={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12};function $6($,Y,X,Z,J){if(TY($,X,Z,"list"))return 6;if(TY($,X,Z,"blockquote"))return 10;if(X===Z)return 4;return J+fM(Y.get(X))}function fM($){if($?.type!=="heading")return 0;if($.depth===1)return 24;return $.depth===2?16:0}function TY($,Y,X,Z){let J=jY($,Y,Z),K=jY($,X,Z);for(let Q of J)if(K.has(Q))return!0;return!1}function jY($,Y,X){let Z=new Set,J=$.get(Y)??null;while(J){if(J.type===X)Z.add(J.id);J=J.parentBlockId?$.get(J.parentBlockId)??null:null}return Z}var mM=["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"],hM=["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 kM($){if($<=255)return mM[$];if(1424<=$&&$<=1524)return"R";if(1536<=$&&$<=1791)return hM[$&255];if(1792<=$&&$<=2220)return"AL";return"L"}function uM($){let Y=$.length;if(Y===0)return null;let X=Array(Y),Z=0;for(let q=0;q<Y;q++){let U=kM($.charCodeAt(q));if(U==="R"||U==="AL"||U==="AN")Z++;X[q]=U}if(Z===0)return null;let J=Y/Z<0.3?0:1,K=new Int8Array(Y);for(let q=0;q<Y;q++)K[q]=J;let Q=J&1?"R":"L",M=Q,D=M;for(let q=0;q<Y;q++)if(X[q]==="NSM")X[q]=D;else D=X[q];D=M;for(let q=0;q<Y;q++){let U=X[q];if(U==="EN")X[q]=D==="AL"?"AN":"EN";else if(U==="R"||U==="L"||U==="AL")D=U}for(let q=0;q<Y;q++)if(X[q]==="AL")X[q]="R";for(let q=1;q<Y-1;q++){if(X[q]==="ES"&&X[q-1]==="EN"&&X[q+1]==="EN")X[q]="EN";if(X[q]==="CS"&&(X[q-1]==="EN"||X[q-1]==="AN")&&X[q+1]===X[q-1])X[q]=X[q-1]}for(let q=0;q<Y;q++){if(X[q]!=="EN")continue;let U;for(U=q-1;U>=0&&X[U]==="ET";U--)X[U]="EN";for(U=q+1;U<Y&&X[U]==="ET";U++)X[U]="EN"}for(let q=0;q<Y;q++){let U=X[q];if(U==="WS"||U==="ES"||U==="ET"||U==="CS")X[q]="ON"}D=M;for(let q=0;q<Y;q++){let U=X[q];if(U==="EN")X[q]=D==="L"?"L":"EN";else if(U==="R"||U==="L")D=U}for(let q=0;q<Y;q++){if(X[q]!=="ON")continue;let U=q+1;while(U<Y&&X[U]==="ON")U++;let V=q>0?X[q-1]:M,G=U<Y?X[U]:M,N=V!=="L"?"R":"L";if(N===(G!=="L"?"R":"L"))for(let _=q;_<U;_++)X[_]=N;q=U-1}for(let q=0;q<Y;q++)if(X[q]==="ON")X[q]=Q;for(let q=0;q<Y;q++){let U=X[q];if((K[q]&1)===0){if(U==="R")K[q]++;else if(U==="AN"||U==="EN")K[q]+=2}else if(U==="L"||U==="AN"||U==="EN")K[q]++}return K}function wY($,Y){let X=uM($);if(X===null)return null;let Z=new Int8Array(Y.length);for(let J=0;J<Y.length;J++)Z[J]=X[Y[J]];return Z}var gM=/[ \t\n\r\f]+/g,IM=/[\t\n\r\f]| {2,}|^ | $/;function pM($){let Y=$??"normal";return Y==="pre-wrap"?{mode:Y,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:Y,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function xM($){if(!IM.test($))return $;let Y=$.replace(gM," ");if(Y.charCodeAt(0)===32)Y=Y.slice(1);if(Y.length>0&&Y.charCodeAt(Y.length-1)===32)Y=Y.slice(0,-1);return Y}function lM($){if(!/[\r\f]/.test($))return $.replace(/\r\n/g,`
|
|
10
17
|
`);return $.replace(/\r\n/g,`
|
|
11
18
|
`).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 n0($){return $.length===1?$[0]:$.join("")}function XY($,M,Z,J){let X=[],Y=null,Q=[],K=Z,q=!1,D=0;for(let V of $){let G=JY(V,J),U=G==="text"&&M;if(Y!==null&&G===Y&&U===q){Q.push(V),D+=V.length;continue}if(Y!==null)X.push({text:n0(Q),isWordLike:q,kind:Y,start:K});Y=G,Q=[V],K=Z+D,q=U,D+=V.length}if(Y!==null)X.push({text:n0(Q),isWordLike:q,kind:Y,start:K});return X}function s8($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var YY=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function QY($,M){let Z=$.texts[M];if(Z.startsWith("www."))return!0;return YY.test(Z)&&M+1<$.len&&$.kinds[M+1]==="text"&&$.texts[M+1]==="//"}function KY($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function DY($){let M=$.texts.slice(),Z=$.isWordLike.slice(),J=$.kinds.slice(),X=$.starts.slice();for(let Q=0;Q<$.len;Q++){if(J[Q]!=="text"||!QY($,Q))continue;let K=[M[Q]],q=Q+1;while(q<$.len&&!s8(J[q])){K.push(M[q]),Z[Q]=!0;let D=M[q].includes("?");if(J[q]="text",M[q]="",q++,D)break}M[Q]=n0(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,Z[Y]=Z[Q],J[Y]=J[Q],X[Y]=X[Q];Y++}return M.length=Y,Z.length=Y,J.length=Y,X.length=Y,{len:Y,texts:M,isWordLike:Z,kinds:J,starts:X}}function qY($){let M=[],Z=[],J=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y];if(M.push(Q),Z.push($.isWordLike[Y]),J.push($.kinds[Y]),X.push($.starts[Y]),!KY(Q))continue;let K=Y+1;if(K>=$.len||s8($.kinds[K]))continue;let q=[],D=$.starts[K],V=K;while(V<$.len&&!s8($.kinds[V]))q.push($.texts[V]),V++;if(q.length>0)M.push(n0(q)),Z.push(!0),J.push("text"),X.push(D),Y=V-1}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}var VY=new Set([":","-","/","×",",",".","+","–","—"]),s9=/^[A-Za-z0-9_]+[,:;]*$/,o9=/[,:;]+$/;function t9($){for(let M of $)if(n9.test(M))return!0;return!1}function o8($){if($.length===0)return!1;for(let M of $){if(n9.test(M)||VY.has(M))continue;return!1}return!0}function UY($){let M=[],Z=[],J=[],X=[];for(let Y=0;Y<$.len;Y++){let Q=$.texts[Y],K=$.kinds[Y];if(K==="text"&&o8(Q)&&t9(Q)){let q=[Q],D=Y+1;while(D<$.len&&$.kinds[D]==="text"&&o8($.texts[D]))q.push($.texts[D]),D++;M.push(n0(q)),Z.push(!0),J.push("text"),X.push($.starts[Y]),Y=D-1;continue}M.push(Q),Z.push($.isWordLike[Y]),J.push(K),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function GY($){let M=[],Z=[],J=[],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],V=o9.test(Q),G=Y+1;while(V&&G<$.len&&$.kinds[G]==="text"&&$.isWordLike[G]&&s9.test($.texts[G])){let U=$.texts[G];D.push(U),V=o9.test(U),G++}M.push(n0(D)),Z.push(!0),J.push("text"),X.push($.starts[Y]),Y=G-1;continue}M.push(Q),Z.push(q),J.push(K),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function AY($){let M=[],Z=[],J=[],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 V=K[D];if(!q)break;if(V.length===0||!t9(V)||!o8(V))q=!1}if(q){let D=0;for(let V=0;V<K.length;V++){let G=K[V],U=V<K.length-1?`${G}-`:G;M.push(U),Z.push(!0),J.push("text"),X.push($.starts[Y]+D),D+=U.length}continue}}M.push(Q),Z.push($.isWordLike[Y]),J.push($.kinds[Y]),X.push($.starts[Y])}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function NY($){let M=[],Z=[],J=[],X=[],Y=0;while(Y<$.len){let Q=[$.texts[Y]],K=$.isWordLike[Y],q=$.kinds[Y],D=$.starts[Y];if(q==="glue"){let V=[Q[0]],G=D;Y++;while(Y<$.len&&$.kinds[Y]==="glue")V.push($.texts[Y]),Y++;let U=n0(V);if(Y<$.len&&$.kinds[Y]==="text")Q[0]=U,Q.push($.texts[Y]),K=$.isWordLike[Y],q="text",D=G,Y++;else{M.push(U),Z.push(!1),J.push("glue"),X.push(G);continue}}else Y++;if(q==="text")while(Y<$.len&&$.kinds[Y]==="glue"){let V=[];while(Y<$.len&&$.kinds[Y]==="glue")V.push($.texts[Y]),Y++;let G=n0(V);if(Y<$.len&&$.kinds[Y]==="text"){Q.push(G,$.texts[Y]),K=K||$.isWordLike[Y],Y++;continue}Q.push(G)}M.push(n0(Q)),Z.push(K),J.push(q),X.push(D)}return{len:M.length,texts:M,isWordLike:Z,kinds:J,starts:X}}function _Y($){let M=$.texts.slice(),Z=$.isWordLike.slice(),J=$.kinds.slice(),X=$.starts.slice();for(let Y=0;Y<M.length-1;Y++){if(J[Y]!=="text"||J[Y+1]!=="text")continue;if(!o0(M[Y])||!o0(M[Y+1]))continue;let Q=tX(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:Z,kinds:J,starts:X}}function FY($,M,Z){let J=dX(),X=0,Y=[],Q=[],K=[],q=[];for(let U of J.segment($))for(let A of XY(U.segment,U.isWordLike??!1,U.index,Z)){let _=A.kind==="text";if(M.carryCJKAfterClosingQuote&&_&&X>0&&K[X-1]==="text"&&o0(A.text)&&o0(Y[X-1])&&$6(Y[X-1]))Y[X-1]+=A.text,Q[X-1]=Q[X-1]||A.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&oX(A.text)&&o0(Y[X-1]))Y[X-1]+=A.text,Q[X-1]=Q[X-1]||A.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&MY(Y[X-1]))Y[X-1]+=A.text,Q[X-1]=Q[X-1]||A.isWordLike;else if(_&&X>0&&K[X-1]==="text"&&A.isWordLike&&i8(A.text)&&$Y(Y[X-1]))Y[X-1]+=A.text,Q[X-1]=!0;else if(_&&!A.isWordLike&&X>0&&K[X-1]==="text"&&A.text.length===1&&A.text!=="-"&&A.text!=="—"&&eX(Y[X-1],A.text))Y[X-1]+=A.text;else if(_&&!A.isWordLike&&X>0&&K[X-1]==="text"&&(sX(A.text)||A.text==="-"&&Q[X-1]))Y[X-1]+=A.text;else Y[X]=A.text,Q[X]=A.isWordLike,K[X]=A.kind,q[X]=A.start,X++}for(let U=1;U<X;U++)if(K[U]==="text"&&!Q[U]&&e8(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]&&nX(Y[U])){let A=U+1;while(A<X&&Y[A]==="")A++;if(A<X&&K[A]==="text")Y[A]=Y[U]+Y[A],q[A]=q[U],Y[U]=""}let D=0;for(let U=0;U<X;U++){let A=Y[U];if(A.length===0)continue;if(D!==U)Y[D]=A,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 V=NY({len:D,texts:Y,isWordLike:Q,kinds:K,starts:q}),G=_Y(GY(AY(UY(qY(DY(V))))));for(let U=0;U<G.len-1;U++){let A=ZY(G.texts[U]);if(A===null)continue;if(G.kinds[U]!=="space"&&G.kinds[U]!=="preserved-space"||G.kinds[U+1]!=="text"||!i8(G.texts[U+1]))continue;G.texts[U]=A.space,G.isWordLike[U]=!1,G.kinds[U]=G.kinds[U]==="preserved-space"?"preserved-space":"space",G.texts[U+1]=A.marks+G.texts[U+1],G.starts[U+1]=G.starts[U]+A.space.length}return G}function zY($,M){if($.len===0)return[];if(!M.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let Z=[],J=0;for(let X=0;X<$.len;X++){if($.kinds[X]!=="hard-break")continue;Z.push({startSegmentIndex:J,endSegmentIndex:X,consumedEndSegmentIndex:X+1}),J=X+1}if(J<$.len)Z.push({startSegmentIndex:J,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return Z}function e9($,M,Z="normal"){let J=gX(Z),X=J.mode==="pre-wrap"?lX($):pX($);if(X.length===0)return{normalized:X,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let Y=FY(X,M,J);return{normalized:X,chunks:zY(Y,J),...Y}}var t1=null,$7=new Map,e1=null,HY=/\p{Emoji_Presentation}/u,EY=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,M6=null,M7=new Map;function Z6(){if(t1!==null)return t1;if(typeof OffscreenCanvas<"u")return t1=new OffscreenCanvas(1,1).getContext("2d"),t1;if(typeof document<"u")return t1=document.createElement("canvas").getContext("2d"),t1;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function WY($){let M=$7.get($);if(!M)M=new Map,$7.set($,M);return M}function Y1($,M){let Z=M.get($);if(Z===void 0)Z={width:Z6().measureText($).width,containsCJK:o0($)},M.set($,Z);return Z}function $2(){if(e1!==null)return e1;if(typeof navigator>"u")return e1={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},e1;let $=navigator.userAgent,Z=navigator.vendor==="Apple Computer, Inc."&&$.includes("Safari/")&&!$.includes("Chrome/")&&!$.includes("Chromium/")&&!$.includes("CriOS/")&&!$.includes("FxiOS/")&&!$.includes("EdgiOS/"),J=$.includes("Chrome/")||$.includes("Chromium/")||$.includes("CriOS/")||$.includes("Edg/");return e1={lineFitEpsilon:Z?0.015625:0.005,carryCJKAfterClosingQuote:J,preferPrefixWidthsForBreakableRuns:Z,preferEarlySoftHyphenBreak:Z},e1}function yY($){let M=$.match(/(\d+(?:\.\d+)?)\s*px/);return M?parseFloat(M[1]):16}function J6(){if(M6===null)M6=new Intl.Segmenter(void 0,{granularity:"grapheme"});return M6}function BY($){return HY.test($)||$.includes("️")}function Z7($){return EY.test($)}function PY($,M){let Z=M7.get($);if(Z!==void 0)return Z;let J=Z6();J.font=$;let X=J.measureText("\uD83D\uDE00").width;if(Z=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)Z=X-Q}return M7.set($,Z),Z}function wY($){let M=0,Z=J6();for(let J of Z.segment($))if(BY(J.segment))M++;return M}function bY($,M){if(M.emojiCount===void 0)M.emojiCount=wY($);return M.emojiCount}function Q1($,M,Z){if(Z===0)return M.width;return M.width-bY($,M)*Z}function J7($,M,Z,J){if(M.graphemeWidths!==void 0)return M.graphemeWidths;let X=[],Y=J6();for(let Q of Y.segment($)){let K=Y1(Q.segment,Z);X.push(Q1(Q.segment,K,J))}return M.graphemeWidths=X.length>1?X:null,M.graphemeWidths}function X7($,M,Z,J){if(M.graphemePrefixWidths!==void 0)return M.graphemePrefixWidths;let X=[],Y=J6(),Q="";for(let K of Y.segment($)){Q+=K.segment;let q=Y1(Q,Z);X.push(Q1(Q,q,J))}return M.graphemePrefixWidths=X.length>1?X:null,M.graphemePrefixWidths}function Y7($,M){let Z=Z6();Z.font=$;let J=WY($),X=yY($),Y=M?PY($,X):0;return{cache:J,fontSize:X,emojiCorrection:Y}}function G5($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function TY($,M){while(M<$.widths.length){let Z=$.kinds[M];if(Z!=="space"&&Z!=="zero-width-break"&&Z!=="soft-hyphen")break;M++}return M}function jY($,M){if(M<=0)return 0;let Z=$%M;if(Math.abs(Z)<=0.000001)return M;return M-Z}function Q7($,M,Z,J){if(!J||M===null)return $[Z];return M[Z]-(Z>0?M[Z-1]:0)}function OY($,M,Z,J,X,Y){let Q=0,K=M;while(Q<$.length){let q=Y?M+$[Q]:K+$[Q];if((Q+1<$.length?q+X:q)>Z+J)break;K=q,Q++}return{fitCount:Q,fittedWidth:K}}function LY($,M,Z){let{widths:J,kinds:X,breakableWidths:Y,breakablePrefixWidths:Q}=$;if(J.length===0)return 0;let K=$2(),q=K.lineFitEpsilon,D=0,V=0,G=!1,U=0,A=0,_=0,N=0,z=-1,E=0;function L(){z=-1,E=0}function W(B=_,P=N,F=V){D++,Z?.({startSegmentIndex:U,startGraphemeIndex:A,endSegmentIndex:B,endGraphemeIndex:P,width:F}),V=0,G=!1,L()}function R(B,P){G=!0,U=B,A=0,_=B+1,N=0,V=P}function S(B,P,F){G=!0,U=B,A=P,_=B,N=P+1,V=F}function I(B,P){if(!G){R(B,P);return}V+=P,_=B+1,N=0}function y(B,P){if(!G5(X[B]))return;z=B+1,E=V-P}function b(B){H(B,0)}function H(B,P){let F=Y[B],C=Q[B]??null;for(let u=P;u<F.length;u++){let h=Q7(F,C,u,K.preferPrefixWidthsForBreakableRuns);if(!G){S(B,u,h);continue}if(V+h>M+q)W(),S(B,u,h);else V+=h,_=B,N=u+1}if(G&&_===B&&N===F.length)_=B+1,N=0}let j=0;while(j<J.length){if(!G){if(j=TY($,j),j>=J.length)break}let B=J[j],P=X[j];if(!G){if(B>M&&Y[j]!==null)b(j);else R(j,B);y(j,B),j++;continue}if(V+B>M+q){if(G5(P)){I(j,B),W(j+1,0,V-B),j++;continue}if(z>=0){if(_>z||_===z&&N>0){W();continue}W(z,0,E);continue}if(B>M&&Y[j]!==null){W(),b(j),j++;continue}W();continue}I(j,B),y(j,B),j++}if(G)W();return D}function K7($,M,Z){if($.simpleLineWalkFastPath)return LY($,M,Z);let{widths:J,lineEndFitAdvances:X,lineEndPaintAdvances:Y,kinds:Q,breakableWidths:K,breakablePrefixWidths:q,discretionaryHyphenWidth:D,tabStopAdvance:V,chunks:G}=$;if(J.length===0||G.length===0)return 0;let U=$2(),A=U.lineFitEpsilon,_=0,N=0,z=!1,E=0,L=0,W=0,R=0,S=-1,I=0,y=0,b=null;function H(){S=-1,I=0,y=0,b=null}function j(T=W,k=R,m=N){_++,Z?.({startSegmentIndex:E,startGraphemeIndex:L,endSegmentIndex:T,endGraphemeIndex:k,width:m}),N=0,z=!1,H()}function B(T,k){z=!0,E=T,L=0,W=T+1,R=0,N=k}function P(T,k,m){z=!0,E=T,L=k,W=T,R=k+1,N=m}function F(T,k){if(!z){B(T,k);return}N+=k,W=T+1,R=0}function C(T,k){if(!G5(Q[T]))return;let m=Q[T]==="tab"?0:X[T],a=Q[T]==="tab"?k:Y[T];S=T+1,I=N-k+m,y=N-k+a,b=Q[T]}function u(T){h(T,0)}function h(T,k){let m=K[T],a=q[T]??null;for(let l=k;l<m.length;l++){let F0=Q7(m,a,l,U.preferPrefixWidthsForBreakableRuns);if(!z){P(T,l,F0);continue}if(N+F0>M+A)j(),P(T,l,F0);else N+=F0,W=T,R=l+1}if(z&&W===T&&R===m.length)W=T+1,R=0}function g(T){if(b!=="soft-hyphen")return!1;let k=K[T];if(k===null)return!1;let m=U.preferPrefixWidthsForBreakableRuns?q[T]??k:k,a=m!==k,{fitCount:l,fittedWidth:F0}=OY(m,N,M,A,D,a);if(l===0)return!1;if(N=F0,W=T,R=l,H(),l===k.length)return W=T+1,R=0,!0;return j(T,l,F0+D),h(T,l),!0}function w(T){_++,Z?.({startSegmentIndex:T.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:T.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),H()}for(let T=0;T<G.length;T++){let k=G[T];if(k.startSegmentIndex===k.endSegmentIndex){w(k);continue}z=!1,N=0,E=k.startSegmentIndex,L=0,W=k.startSegmentIndex,R=0,H();let m=k.startSegmentIndex;while(m<k.endSegmentIndex){let a=Q[m],l=a==="tab"?jY(N,V):J[m];if(a==="soft-hyphen"){if(z)W=m+1,R=0,S=m+1,I=N+D,y=N+D,b=a;m++;continue}if(!z){if(l>M&&K[m]!==null)u(m);else B(m,l);C(m,l),m++;continue}if(N+l>M+A){let c0=N+(a==="tab"?0:X[m]),k0=N+(a==="tab"?l:Y[m]);if(b==="soft-hyphen"&&U.preferEarlySoftHyphenBreak&&I<=M+A){j(S,0,y);continue}if(b==="soft-hyphen"&&g(m)){m++;continue}if(G5(a)&&c0<=M+A){F(m,l),j(m+1,0,k0),m++;continue}if(S>=0&&I<=M+A){if(W>S||W===S&&R>0){j();continue}let m0=S;j(m0,0,y),m=m0;continue}if(l>M&&K[m]!==null){j(),u(m),m++;continue}j();continue}F(m,l),C(m,l),m++}if(z){let a=S===k.consumedEndSegmentIndex?y:N;j(k.consumedEndSegmentIndex,0,a)}}return _}var X6=null,D7=new WeakMap;function V7(){if(X6===null)X6=new Intl.Segmenter(void 0,{granularity:"grapheme"});return X6}function CY($){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 RY($,M,Z){let J=V7(),X=$2(),{cache:Y,emojiCorrection:Q}=Y7(M,Z7($.normalized)),K=Q1("-",Y1("-",Y),Q),D=Q1(" ",Y1(" ",Y),Q)*8;if($.len===0)return CY(Z);let V=[],G=[],U=[],A=[],_=$.chunks.length<=1,N=Z?[]:null,z=[],E=[],L=Z?[]:null,W=Array.from({length:$.len}),R=Array.from({length:$.len});function S(b,H,j,B,P,F,C,u){if(P!=="text"&&P!=="space"&&P!=="zero-width-break")_=!1;if(V.push(H),G.push(j),U.push(B),A.push(P),N?.push(F),z.push(C),E.push(u),L!==null)L.push(b)}for(let b=0;b<$.len;b++){W[b]=V.length;let H=$.texts[b],j=$.isWordLike[b],B=$.kinds[b],P=$.starts[b];if(B==="soft-hyphen"){S(H,0,K,K,B,P,null,null),R[b]=V.length;continue}if(B==="hard-break"){S(H,0,0,0,B,P,null,null),R[b]=V.length;continue}if(B==="tab"){S(H,0,0,0,B,P,null,null),R[b]=V.length;continue}let F=Y1(H,Y);if(B==="text"&&F.containsCJK){let g="",w=0;for(let T of J.segment(H)){let k=T.segment;if(g.length===0){g=k,w=T.index;continue}if(v2.has(g)||n8.has(k)||n1.has(k)||X.carryCJKAfterClosingQuote&&o0(k)&&$6(g)){g+=k;continue}let m=Y1(g,Y),a=Q1(g,m,Q);S(g,a,a,a,"text",P+w,null,null),g=k,w=T.index}if(g.length>0){let T=Y1(g,Y),k=Q1(g,T,Q);S(g,k,k,k,"text",P+w,null,null)}R[b]=V.length;continue}let C=Q1(H,F,Q),u=B==="space"||B==="preserved-space"||B==="zero-width-break"?0:C,h=B==="space"||B==="zero-width-break"?0:C;if(j&&H.length>1){let g=J7(H,F,Y,Q),w=X.preferPrefixWidthsForBreakableRuns?X7(H,F,Y,Q):null;S(H,C,u,h,B,P,g,w)}else S(H,C,u,h,B,P,null,null);R[b]=V.length}let I=SY($.chunks,W,R),y=N===null?null:i9($.normalized,N);if(L!==null)return{widths:V,lineEndFitAdvances:G,lineEndPaintAdvances:U,kinds:A,simpleLineWalkFastPath:_,segLevels:y,breakableWidths:z,breakablePrefixWidths:E,discretionaryHyphenWidth:K,tabStopAdvance:D,chunks:I,segments:L};return{widths:V,lineEndFitAdvances:G,lineEndPaintAdvances:U,kinds:A,simpleLineWalkFastPath:_,segLevels:y,breakableWidths:z,breakablePrefixWidths:E,discretionaryHyphenWidth:K,tabStopAdvance:D,chunks:I}}function SY($,M,Z){let J=[];for(let X=0;X<$.length;X++){let Y=$[X],Q=Y.startSegmentIndex<M.length?M[Y.startSegmentIndex]:Z[Z.length-1]??0,K=Y.endSegmentIndex<M.length?M[Y.endSegmentIndex]:Z[Z.length-1]??0,q=Y.consumedEndSegmentIndex<M.length?M[Y.consumedEndSegmentIndex]:Z[Z.length-1]??0;J.push({startSegmentIndex:Q,endSegmentIndex:K,consumedEndSegmentIndex:q})}return J}function kY($,M,Z,J){let X=e9($,$2(),J?.whiteSpace);return RY(X,M,Z)}function U7($,M,Z){return kY($,M,!0,Z)}function mY($){return $}function q7($,M,Z){let J=Z.get($);if(J!==void 0)return J;J=[];let X=V7();for(let Y of X.segment(M[$]))J.push(Y.segment);return Z.set($,J),J}function fY($){let M=D7.get($);if(M!==void 0)return M;return M=new Map,D7.set($,M),M}function vY($,M,Z,J){return J>0&&$[J-1]==="soft-hyphen"&&!(M===J&&Z>0)}function uY($,M,Z,J,X,Y,Q){let K="",q=vY(M,J,X,Y);for(let D=J;D<Y;D++){if(M[D]==="soft-hyphen"||M[D]==="hard-break")continue;if(D===J&&X>0)K+=q7(D,$,Z).slice(X).join("");else K+=$[D]}if(Q>0){if(q)K+="-";K+=q7(Y,$,Z).slice(J===Y?X:0,Q).join("")}else if(q)K+="-";return K}function hY($,M,Z,J,X,Y,Q){return{text:uY($.segments,$.kinds,M,J,X,Y,Q),width:Z,start:{segmentIndex:J,graphemeIndex:X},end:{segmentIndex:Y,graphemeIndex:Q}}}function IY($,M,Z){return hY($,M,Z.width,Z.startSegmentIndex,Z.startGraphemeIndex,Z.endSegmentIndex,Z.endGraphemeIndex)}function G7($,M,Z){let J=[];if($.widths.length===0)return{lineCount:0,height:0,lines:J};let X=fY($),Y=K7(mY($),M,(Q)=>{J.push(IY($,X,Q))});return{lineCount:Y,height:Y*Z,lines:J}}var A7=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],A5;function M2($){if($?.type==="heading"){let{fontSize:M}=F7($.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 T1($,M){if($?.type==="heading")return F7($.depth).lineHeight;if($?.type==="code")return 22;return M}function F7($){return A7[$-1]??A7.at(-1)}function Z2($,M,Z,J,X,Y,Q){let K=`${_5(M,Q)}:${X}:${Y}:${Z}`,q=$.measuredLines.get(K);if(q)return q;let D=pY($,M,Z,J,X,Y,Q);return l9($,K,D)}function N5($,M,Z,J,X,Y,Q,K){let q=`${_5(M,K)}:${Z}:${J}:${Y}:${Q}`,D=$.lineBoundaries.get(q);if(D)return D;let V=H7();if(!V)return _7(X);let G=[{left:0,offset:0}],U=0,A=M.inlines.filter((_)=>_.end>Z&&_.start<J);if(A.length===0)return _7(X);for(let _ of A){let N=Math.max(Z,_.start),z=Math.min(J,_.end),E=M.text.slice(N,z),L=N-Z;if(_.kind==="image"){let W=q5(_,K,Q).width;U+=W,L+=E.length,G.push({left:U,offset:L});continue}V.font=z7(Y,_.marks);for(let W of Array.from(E))U+=E7($,V,W),L+=W.length,G.push({left:U,offset:L})}return x9($,q,G)}function gY($,M,Z,J){let X=`${Z}::${J}::${M}`,Y=$.preparedText.get(X);if(Y)return Y;let Q=U7(M,Z,{whiteSpace:J});return p9($,X,Q)}function pY($,M,Z,J,X,Y,Q){let K=M.text;if(K.length===0)return[{end:0,height:Y,start:0,text:"",width:0}];if(cY(M))return xY($,M,Z,X,Y,Q);try{let q=gY($,K,Z,nY(J));return G7(q,X,Y).lines.map((V)=>({end:N7(q.segments,V.end),height:Y,start:N7(q.segments,V.start),text:V.text,width:V.width}))}catch{return lY(K,X,Y)}}function N7($,M){let Z=0;for(let Y=0;Y<M.segmentIndex;Y+=1)Z+=$[Y]?.length??0;let J=$[M.segmentIndex]??"",X=Array.from(J);for(let Y=0;Y<M.graphemeIndex;Y+=1)Z+=X[Y]?.length??0;return Z}function _7($){let M=[{left:0,offset:0}],Z=0,J=0;for(let X of Array.from($))Z+=9,J+=X.length,M.push({left:Z,offset:J});return M}function lY($,M,Z){let J=Math.max(1,Math.floor(M/9)),X=tY($,J),Y=0;return X.map((Q)=>{let K=Y,q=K+Q.length;return Y=q,{end:q,height:Z,start:K,text:Q,width:Q.length*9}})}function xY($,M,Z,J,X,Y){let Q=rY($,H7(),M,Z,J,X,Y);if(Q.length===0)return[{end:0,height:X,start:0,text:"",width:0}];return dY(Q,M.text,J,X)}function dY($,M,Z,J){let X=[],Y=0;while(Y<$.length){let Q=$[Y].start;if($[Y].text===`
|
|
14
|
-
`){
|
|
15
|
-
`)break;let _=
|
|
16
|
-
`){let A=$[
|
|
17
|
-
`?
|
|
18
|
-
|
|
19
|
-
`),J=[];for(let X of Z){if(X.length===0){J.push("");continue}let Y=X;while(Y.length>M){let Q=Y.slice(0,M),K=Q.lastIndexOf(" ");if(K<=0){J.push(Q),Y=Y.slice(M);continue}J.push(Q.slice(0,K)),Y=Y.slice(K+1)}J.push(Y)}return J}var u2=10,J2=8,Y6=120;function W7($,M,Z,J,X,Y,Q,K,q,D){let V=Math.max(1,...Y.rows.map((N)=>N.cells.length)),U=Math.max(Y6,q.width-Q-q.paddingX)/V,A=eY(J),_=K;for(let N=0;N<Y.rows.length;N+=1){let z=$Q(A.get(N)??[],X,Y,U,u2,q.lineHeight,D),E=Math.max(q.lineHeight+J2*2,...z.map((L)=>L.measuredLines.reduce((W,R)=>W+R.height,0)+J2*2));for(let L of z){let W=Q+L.cellIndex*U,R=_+J2;for(let S of L.measuredLines){let I={blockId:L.container.blockId,boundaries:N5(X,L.container,S.start,S.end,S.text,L.font,U-u2*2,D),regionId:L.container.id,end:S.end,font:L.font,height:S.height,left:W+u2,start:S.start,text:S.text,top:R,width:S.width};$.push(I),Q6(M,I),R+=S.height}Z.set(L.container.id,{bottom:_+E,left:W,right:W+U,top:_})}ZQ(M,Y.id,_,_+E),_+=E}return _+q.blockGap}function eY($){let M=new Map;for(let Z of $){let J=MQ(Z.path);if(!J)continue;let X=M.get(J.rowIndex)??[];X.push({cellIndex:J.cellIndex,container:Z}),M.set(J.rowIndex,X)}return M}function $Q($,M,Z,J,X,Y,Q){return[...$].sort((K,q)=>K.cellIndex-q.cellIndex).map(({cellIndex:K,container:q})=>{let D=M2(Z),V=T1(Z,Y),G=Z2(M,q,D,Z,Math.max(40,J-X*2),V,Q);return{cellIndex:K,container:q,font:D,lineHeight:V,measuredLines:G}})}function MQ($){let M=/\.rows\.(\d+)\.cells\.(\d+)$/.exec($);if(!M)return null;return{cellIndex:Number(M[2]),rowIndex:Number(M[1])}}function ZQ($,M,Z,J){let X=$.get(M);$.set(M,{bottom:X?Math.max(X.bottom,J):J,top:X?Math.min(X.top,Z):Z})}var JQ={blockGap:16,charWidth:9,indentWidth:24,lineHeight:24,paddingX:16,paddingY:12},XQ=24,YQ=16,QQ=6,KQ=10,DQ=4;function F5($){let M=Math.max(12,Math.floor($.width/9)),Z=Math.max(1,Math.ceil($.text.length/M));return{estimatedHeight:Z*24,lineCount:Z,width:$.width}}function z5($,M,Z=b1(),J=null){let X=J??{images:new Map},Y={...JQ,...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])),V=new Map($.blocks.map((N)=>[N.id,N])),G=I2($.document.blocks),U=new Map,A=Y.paddingY;for(let N=0;N<$.regions.length;N+=1){let z=$.regions[N],E=D.get(z.blockId)??0,L=Y.paddingX+E*Y.indentWidth,W=Math.max(40,Y.width-L-Y.paddingX),R=G.get(z.blockId)??null;if(R?.type==="table"){let y=V.get(z.blockId)?.regionIds??[],b=$.regions.slice(N,N+y.length);A=W7(Q,U,K,b,Z,R,L,A,Y,X),N+=b.length-1;continue}A=qQ(Q,U,K,z,Z,R,L,A,W,Y,X);let S=E5(V,G,$.regions,N,Y.blockGap);A+=S;let I=U.get(z.blockId);if(I)I.bottom=Math.max(I.bottom,A)}return{blocks:$.blocks.map((N)=>{let z=U.get(N.id),E=z?.top??Y.paddingY;return{bottom:z?.bottom??E+Y.lineHeight/2,depth:N.depth,id:N.id,top:E,type:N.type}}),regionBounds:UQ(Q,K),regionLineIndices:VQ(Q),regionMetrics:q,height:Math.max(A,Y.paddingY),lines:Q,options:Y,width:Y.width}}function qQ($,M,Z,J,X,Y,Q,K,q,D,V){let G=M2(Y),U=T1(Y,D.lineHeight),A=Z2(X,J,G,Y,q,U,V),_=K;for(let N of A){let z={blockId:J.blockId,boundaries:N5(X,J,N.start,N.end,N.text,G,q,V),regionId:J.id,end:N.end,font:G,height:N.height,left:Q,start:N.start,text:N.text,top:_,width:N.width};$.push(z),Q6(M,z),_+=N.height}return GQ($,J.id,Z),_}function VQ($){let M=[...$].sort((J,X)=>J.top-X.top||J.left-X.left),Z=new Map;$.length=0,$.push(...M);for(let[J,X]of $.entries()){let Y=Z.get(X.regionId)??[];Y.push(J),Z.set(X.regionId,Y)}return Z}function UQ($,M){let Z=new Map(M);for(let J of $){let X=Z.get(J.regionId),Y={bottom:J.top+J.height,left:J.left,right:J.left+J.width,top:J.top};Z.set(J.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 Z}function GQ($,M,Z){let J=$.filter((X)=>X.regionId===M);if(J.length===0)return;Z.set(M,{bottom:Math.max(...J.map((X)=>X.top+X.height)),left:Math.min(...J.map((X)=>X.left)),right:Math.max(...J.map((X)=>X.left+X.width)),top:Math.min(...J.map((X)=>X.top))})}function Q6($,M){let Z=$.get(M.blockId),J=M.top+M.height;$.set(M.blockId,{bottom:Z?Math.max(Z.bottom,J):J,top:Z?Math.min(Z.top,M.top):M.top})}function b7($,M){let Z=0,J=$.lines.length-1;while(Z<=J){let X=Z+J>>1,Y=$.lines[X];if(M<Y.top){J=X-1;continue}if(M>=Y.top+Y.height){Z=X+1;continue}return{index:X,line:Y}}return null}function K6($,M){let Z=[...$.regionBounds.entries()].find(([,Y])=>{return M.x>=Y.left&&M.x<=Y.right&&M.y>=Y.top&&M.y<=Y.bottom});if(Z)return H5($,Z[0],M.y);let J=b7($,M.y);if(!J)return null;let X=AQ($,M.y,J.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=y7(M.x,K),V=y7(M.x,q);return D-V})[0]??null}function D6($,M,Z){if($.lines.length===0)return{endIndex:0,startIndex:0};let J=M+Z,X=B7($,M),Y=B7($,J);if(X>0){let Q=$.lines[X-1];if(Q.top+Q.height>M)X-=1}if(Y<$.lines.length){if($.lines[Y].top<J)Y+=1}return{endIndex:Y,startIndex:X}}function g0($,M,Z){if(!$.regionMetrics.get(Z.regionId))return null;let X=L0($,Z.regionId,Z.offset);if(!X)return null;return{blockId:X.blockId,regionId:X.regionId,height:X.height,left:y0(X,Z.offset-X.start),offset:Z.offset,top:X.top}}function L0($,M,Z){return h2($,M,Z)?.line??null}function H5($,M,Z){let J=$.regionLineIndices.get(M);if(!J||J.length===0)return null;let X=J[0],Y=Number.POSITIVE_INFINITY;for(let Q of J){let K=$.lines[Q],q=Z<K.top?K.top-Z:Z>K.top+K.height?Z-(K.top+K.height):0;if(q<Y)Y=q,X=Q;if(q===0)break}return{index:X,line:$.lines[X]}}function h2($,M,Z){let J=$.regionLineIndices.get(M);if(!J||J.length===0)return null;let X=0,Y=J.length-1;while(X<=Y){let V=X+Y>>1,G=J[V],U=$.lines[G];if(Z<U.start){Y=V-1;continue}if(Z>U.end){X=V+1;continue}return{index:G,line:U}}let Q=J[0],K=J[J.length-1],q=$.lines[Q],D=$.lines[K];if(Z<=q.start)return{index:Q,line:q};if(Z>=D.end)return{index:K,line:D};return null}function AQ($,M,Z){let J=[];for(let X=Z;X>=0;X-=1){let Y=$.lines[X];if(M<Y.top||M>=Y.top+Y.height)break;J.unshift({index:X,line:Y})}for(let X=Z+1;X<$.lines.length;X+=1){let Y=$.lines[X];if(M<Y.top||M>=Y.top+Y.height)break;J.push({index:X,line:Y})}return J}function y7($,M){if(!M)return Number.POSITIVE_INFINITY;if($<M.left)return M.left-$;if($>M.right)return $-M.right;return 0}function y0($,M){return $.left+NQ($.boundaries,M)}function I2($){let M=new Map,Z=(J)=>{for(let X of J)if(M.set(X.id,X),X.type==="blockquote"||X.type==="listItem")Z(X.children);else if(X.type==="list")Z(X.items)};return Z($),M}function NQ($,M){for(let J of $)if(J.offset===M)return J.left;return $.filter((J)=>J.offset<=M).at(-1)?.left??0}function B7($,M){let Z=0,J=$.lines.length;while(Z<J){let X=Z+J>>1,Y=$.lines[X];if(Y.top+Y.height<=M)Z=X+1;else J=X}return Z}function T7($,M){if($.length===0)return 0;for(let Z=1;Z<$.length;Z+=1){let J=$[Z-1],X=$[Z],Y=J.left+(X.left-J.left)/2;if(M<=Y)return J.offset;if(M<=X.left)return X.offset}return $.at(-1)?.offset??0}function E5($,M,Z,J,X){let Y=Z[J],Q=Z[J+1];if(!Y||!Q)return X;if(P7($,Y.blockId,Q.blockId,"list"))return QQ;if(P7($,Y.blockId,Q.blockId,"blockquote"))return KQ;if(Y.blockId===Q.blockId)return DQ;return X+_Q(M.get(Y.blockId))}function _Q($){if($?.type!=="heading")return 0;if($.depth===1)return XQ;return $.depth===2?YQ:0}function P7($,M,Z,J){let X=w7($,M,J),Y=w7($,Z,J);for(let Q of X)if(Y.has(Q))return!0;return!1}function w7($,M,Z){let J=new Set,X=$.get(M)??null;while(X){if(X.type===Z)J.add(X.id);X=X.parentBlockId?$.get(X.parentBlockId)??null:null}return J}function q6($,M,Z,J=[],X=b1(),Y=null){let Q=Y??{images:new Map},K=I2($.document.blocks),q=new Map($.blocks.map((W)=>[W.id,W])),D=new Set(J),V=Math.max(0,Z.top-Z.overscan),G=Z.top+Z.height+Z.overscan,U=WQ(X,$,K,q,M,Q),A=j7(U,V),_=j7(U,G);if(A>0){let W=U.entries[A-1];if(W&&W.bottom>V)A-=1}if(_<U.entries.length){let W=U.entries[_];if(W&&W.top<G)_+=1}for(let W of D){let R=U.containerIndices.get(W);if(R===void 0)continue;A=Math.min(A,R),_=Math.max(_,R+1)}if(!Number.isFinite(A)||!Number.isFinite(_))return{estimateRegionBounds:U.estimateRegionBounds,layout:z5({...$,regions:[]},M,X,Q),totalHeight:U.totalHeight,viewport:Z};let N=HQ($,q,U.containerIndices,A,_),z=U.entries[N.startIndex]?.top??M.paddingY??0,E=z5({...$,regions:$.regions.slice(N.startIndex,N.endIndex)},M,X,Q),L=zQ(E,z,U.totalHeight);return FQ(X,$,L,M,Q),{estimateRegionBounds:U.estimateRegionBounds,layout:L,totalHeight:U.totalHeight,viewport:Z}}function FQ($,M,Z,J,X){for(let[Y,Q]of Z.regionBounds){let K=Q.bottom-Q.top,q=M.regionIndex.get(Y);d9($,O7(q??{path:Y,inlines:[],text:""},J,X),K)}}function zQ($,M,Z){return{...$,blocks:$.blocks.map((J)=>({...J,bottom:J.bottom+M,top:J.top+M})),regionBounds:new Map([...$.regionBounds.entries()].map(([J,X])=>[J,{bottom:X.bottom+M,left:X.left,right:X.right,top:X.top+M}])),height:Z,lines:$.lines.map((J)=>({...J,top:J.top+M}))}}function HQ($,M,Z,J,X){let Y=J,Q=X;for(let K=J;K<X;K+=1){let q=$.regions[K],D=M.get(q.blockId);if(!D)continue;if(D.type==="table"){let V=Z.get(D.regionIds[0]??""),G=Z.get(D.regionIds[D.regionIds.length-1]??"");if(V!==void 0)Y=Math.min(Y,V);if(G!==void 0)Q=Math.max(Q,G+1)}}return{endIndex:Q,startIndex:Y}}function EQ($,M,Z,J,X,Y){let Q=O7(M,X,Y),K=$.measuredContainerHeights.get(Q);if(K!==void 0)return K;let q=X.paddingX??0,D=X.indentWidth??24,V=T1(Z,X.lineHeight??24),G=q+J*D,U=Math.max(40,X.width-G-q);if(M.inlines.some((N)=>N.kind==="image")){let N=M2(Z);return Z2($,M,N,Z,U,V,Y).reduce((z,E)=>z+E.height,0)}let A=F5({text:M.text,width:U});return Math.max(V,A.lineCount*V)}function WQ($,M,Z,J,X,Y){let Q=wQ(M,X,Y),K=c9($,M,Q);if(K)return K;let q=X.paddingY??0,D=[],V=new Map;for(let G=0;G<M.regions.length;G+=1){let U=M.regions[G],A=Z.get(U.blockId)??null;if(A?.type==="table"){let E=yQ({block:A,blockMap:Z,containerIndices:V,entries:D,index:G,options:X,runtimeBlocks:J,totalHeight:q,regions:M.regions});if(E){G=E.nextIndex-1,q=E.totalHeight;continue}}let _=EQ($,U,A,J.get(U.blockId)?.depth??0,X,Y),N=q,z=N+_;D.push({bottom:z,top:N}),V.set(U.id,G),q=z+E5(J,Z,M.regions,G,X.blockGap??16)}return a9($,M,Q,{containerIndices:V,entries:D,estimateRegionBounds(G){let U=V.get(G);return U===void 0?null:D[U]??null},totalHeight:q})}function yQ({block:$,blockMap:M,containerIndices:Z,entries:J,index:X,options:Y,runtimeBlocks:Q,totalHeight:K,regions:q}){let D=Q.get($.id),V=D?.regionIds??[];if(V.length===0)return null;let G=q.slice(X,X+V.length);if(G.length===0||G[0]?.blockId!==$.id)return null;let U=Y.paddingX??0,A=Y.indentWidth??24,_=D?.depth??0,N=U+_*A,z=Math.max(Y6,Y.width-N-U),E=Math.max(1,...$.rows.map((y)=>y.cells.length)),L=z/E,W=Math.max(40,L-u2*2),R=T1($,Y.lineHeight??24),S=BQ(G,X),I=K;for(let y=0;y<$.rows.length;y+=1){let b=S.get(y)??[],H=Math.max(R+J2*2,...b.map(({region:B})=>PQ(B,W,R)+J2*2)),j=I+H;for(let{index:B,region:P}of b)J[B]={bottom:j,top:I},Z.set(P.id,B);I=j}for(let y=X;y<X+G.length;y+=1){let b=q[y];if(!b||J[y])continue;J[y]={bottom:I,top:I},Z.set(b.id,y)}return{nextIndex:X+G.length,totalHeight:I+E5(Q,M,q,X+G.length-1,Y.blockGap??16)}}function BQ($,M){let Z=new Map;for(let[J,X]of $.entries()){let Y=X.tableCellPosition?.rowIndex;if(Y===void 0)continue;let Q=Z.get(Y)??[];Q.push({index:M+J,region:X}),Z.set(Y,Q)}return Z}function PQ($,M,Z){let J=F5({text:$.text,width:M});return Math.max(Z,J.lineCount*Z)}function wQ($,M,Z){return[M.width,M.paddingX??0,M.paddingY??0,M.indentWidth??24,M.lineHeight??24,M.blockGap??16,bQ($,Z)].join(":")}function j7($,M){let Z=0,J=$.entries.length;while(Z<J){let X=Z+J>>1;if($.entries[X].bottom<=M)Z=X+1;else J=X}return Z}function O7($,M,Z){return`${_5($,Z)}:${M.width}:${M.paddingX??0}:${M.indentWidth??24}:${M.lineHeight??24}`}function bQ($,M){return $.regions.flatMap((Z)=>Z.inlines.filter((J)=>J.kind==="image"&&J.image).map((J)=>{let X=J.image?M.images.get(J.image.url):null;return`${J.image?.url??""}:${J.image?.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`})).join("|")}var W5=null;function TQ($){let M=/(\d+(?:\.\d+)?)\s*px/.exec($);return M?Number.parseFloat(M[1]):16}function K1($){W5??=new Map;let M=W5.get($);if(M)return M;let Z=R7(),J=Math.max(12,Math.round(TQ($)));if(!Z){let U={ascent:Math.round(J*0.8),descent:Math.max(2,J-Math.round(J*0.8)),emHeight:J};return W5.set($,U),U}Z.font=$;let X=Z.measureText("Hg"),Y=Math.round(X.actualBoundingBoxAscent||0),Q=Math.round(X.actualBoundingBoxDescent||0),K=Y+Q,q=Math.max(J,K),D=K>0?Y:Math.round(q*0.8),V=K>0?Q:Math.max(2,q-D),G={ascent:D,descent:V,emHeight:q};return W5.set($,G),G}function jQ($,M){let{emHeight:Z}=K1(M);return Math.max(0,Math.floor(($-Z)/2))}function L7($,M){let{ascent:Z}=K1(M);return jQ($,M)+Z}var y5;function C7($,M){let Z=R7();if(!Z||$.length===0)return 0;return Z.font=M,Z.measureText($).width}function R7(){if(y5!==void 0)return y5;return y5=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,y5}var OQ=18,LQ=14,CQ=22;function b0($,M,Z){let J=SQ($,Z);if(!J)return null;return S7($,M,J,Z.x)}function V6($,M,Z){let J=$.lines[$.lines.length-1];if(!J||Z.y<=J.top+J.height)return null;return S7($,M,J,Z.x)}function S7($,M,Z,J){let X=$.regionMetrics.get(Z.regionId);if(!X)return null;let Y=Math.max(0,J-I0(M,Z)-Z.left),Q=T7(Z.boundaries,Y),K=Math.min(X.textLength,Z.start+Q);return{regionId:Z.regionId,offset:K,left:y0(Z,Q),top:Z.top,height:Z.height}}function U6($,M,Z,J){let X=F6(M,J.regionId);if(!X)return null;let Y=b0($,M,Z);if(Y)return{regionId:Y.regionId,offset:Y.offset};let Q=Z.y<mQ($);return{regionId:J.regionId,offset:Q?0:X.text.length}}function G6($,M,Z){let J=b0($,M,Z);if(!J)return null;let X=F6(M,J.regionId);if(!X||X.text.length===0)return null;let Y=J.offset<X.text.length&&/\w/.test(X.text[J.offset]??"")?J.offset:J.offset>0&&/\w/.test(X.text[J.offset-1]??"")?J.offset-1:J.offset,Q=fQ(X.text,Y);if(Q.start===Q.end)return null;return{anchor:{regionId:J.regionId,offset:Q.start},focus:{regionId:J.regionId,offset:Q.end}}}function k7($,M,Z){let J=kQ($,Z);if(!J||J.start!==0)return null;let X=X2(M,J.blockId,"listItem");if(!X)return null;if(p2(M,X.id)?.kind!=="task")return null;let Q=g2(J),K=Q.left-4,q=Q.left+Q.size+4,D=Q.top-4,V=Q.top+Q.size+4;return Z.x>=K&&Z.x<=q&&Z.y>=D&&Z.y<=V?{listItemId:X.id}:null}function m7($,M,Z){let J=b0($,M,Z);if(!J)return null;let X=F6(M,J.regionId);if(!X)return null;let Y=X.inlines.find((K)=>K.link&&J.offset>=K.start&&J.offset<K.end);if(!Y?.link)return null;let Q=_6($,M,J.regionId,Y.start);if(!Q)return null;return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,endOffset:Y.end,regionId:J.regionId,startOffset:Y.start,title:Y.link.title,url:Y.link.url}}function A6($,M,Z,J){let X=k7($,M,Z);if(X)return{kind:"task-toggle",listItemId:X.listItemId};let Y=b0($,M,Z);if(!Y)return null;let Q=f7(Y.regionId,Y.offset,J),K=Q!==null?v7(Q,$,M,J):null,q=m7($,M,Z);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 N6($,M,Z,J){let X=M.documentIndex.regionIndex.get(Z.regionId);if(!X)return null;let Y=f7(Z.regionId,Z.offset,J),Q=Y!==null?v7(Y,$,M,J):null,K=X.inlines.find((q)=>Z.offset>=q.start&&Z.offset<=q.end)??null;if(K?.link){let q=_6($,M,Z.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:Z.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 p0($,M,Z){let J=L0(M,Z.regionId,Z.offset);if(!J)return Z.left;return Z.left+I0($,J)+RQ($,J,Z.offset)}function D1($,M,Z){return y0(M,Z)+I0($,M)}function I0($,M){let Z=X2($,M.blockId,"listItem");if(!Z)return 0;return p2($,Z.id)?.kind==="task"?CQ:OQ}function g2($){return{left:$.left,size:LQ,top:$.top+3}}function X2($,M,Z){let J=$.documentIndex.blockIndex.get(M)??null;while(J){if(J.type===Z)return J;let X=J.parentBlockId;J=X?$.documentIndex.blockIndex.get(X)??null:null}return null}function p2($,M){return $.documentIndex.listItemMarkers.get(M)??null}function f7($,M,Z){for(let J of Z)if(J.regionId===$&&M>=J.startOffset&&M<=J.endOffset)return J.threadIndex;return null}function v7($,M,Z,J){let X=J.find((Y)=>Y.threadIndex===$);if(!X)return null;return _6(M,Z,X.regionId,X.startOffset)}function _6($,M,Z,J){let X=L0($,Z,J);if(!X)return null;return{anchorBottom:X.top+X.height,anchorLeft:y0(X,J)+I0(M,X)}}function RQ($,M,Z){if(Z<=M.end)return 0;let J=$.documentIndex.regionIndex.get(M.regionId);if(!J)return 0;let X=J.text.slice(M.end,Z);if(!/^[ \t]+$/u.test(X))return 0;return C7(X,M.font)}function SQ($,M){for(let[J,X]of $.regionBounds)if(M.x>=X.left&&M.x<=X.right&&M.y>=X.top&&M.y<=X.bottom)return H5($,J,M.y)?.line??null;let Z=K6($,M)?.line??null;if(Z)return Z;for(let J of $.blocks)if(M.y>=J.top&&M.y<=J.bottom){for(let X=$.lines.length-1;X>=0;X--)if($.lines[X].blockId===J.id)return $.lines[X]}return null}function kQ($,M){return $.lines.find((Z)=>M.y>=Z.top-4&&M.y<=Z.top+Z.height+4)??$.lines.filter((Z)=>Math.abs(M.y-(Z.top+Z.height/2))<=10).sort((Z,J)=>Math.abs(M.y-(Z.top+Z.height/2))-Math.abs(M.y-(J.top+J.height/2)))[0]??null}function F6($,M){return $.documentIndex.regionIndex.get(M)??null}function mQ($){return $.lines[0]?.top??0}function fQ($,M){let Z=M,J=M;while(Z>0&&/\w/.test($[Z-1]??""))Z-=1;while(J<$.length&&/\w/.test($[J]??""))J+=1;return{end:J,start:Z}}function z6($,M,Z,J=null){let X={height:M.height,overscan:Math.max(160,M.height),top:M.top},Y=q6($.documentIndex,M,X,[$.selection.anchor.regionId,$.selection.focus.regionId],Z,J);return{blockMap:I2($.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 B5($,M,Z){return b0(M.layout,$,Z)??V6(M.layout,$,Z)}function l2($,M,Z,J){return U6(M.layout,$,Z,J)}function H6($,M,Z){return G6(M.layout,$,Z)}function E6($,M,Z,J){return A6(M.layout,$,Z,J)}function W6($,M,Z,J){return N6(M.layout,$,Z,J)}function y6($,M,Z){return g0(M.layout,$.documentIndex,Z)}function t0($,M,Z){let J=g0(M.layout,$.documentIndex,Z);if(!J)return null;return{...J,left:p0($,M.layout,J)}}function u7($,M,Z,J,X){let Y=J-Z,Q=X-Y;if(J<=$)return{end:M+Q,start:$+Q};if(Z>=M)return{end:M,start:$};let K=Math.max(0,Math.min(Z,M)-$),q=Math.max(0,M-Math.max(J,$)),D=$<Z?$:Z;return{end:D+K+X+q,start:D}}function P6($,M,Z){let J=Z.trim();if(J.length===0||M.startOffset===M.endOffset)return null;let X=$.regionIndex.get(M.regionId)??null,Y=X?B6($,X):null;if(!Y)return null;return g8({anchor:S2(Y,M.startOffset,M.endOffset),body:J,quote:k2(Y,M.startOffset,M.endOffset)})}function C0($){let M="documentIndex"in $?$.documentIndex:$,Z=P5(M),J=M.document.comments,X=[...J],Y=[];for(let[Q,K]of J.entries()){let q=m2(K,M.document);if(!q.match)continue;let V=Z.findBySemanticMatch(q.match.containerId,q.match.containerOrdinal)?.runtimeContainer??null;if(!V)continue;if(q.repair)X[Q]={...K,anchor:q.repair.anchor,quote:q.repair.quote};Y.push({endOffset:q.match.endOffset,resolution:q,regionId:V.id,resolved:K.resolvedAt!=null,startOffset:q.match.startOffset,threadIndex:Q})}return{liveRanges:Y,threads:X}}function w6($,M,Z,J,X,Y){if($.document.comments.length===0)return M.document.comments;let Q=$.commentContainerIndex.get(Z.semanticRegionId)??[],K=new Set(Q);if(Q.length===0)return M.document.comments;let q=C0($),D=new Map(q.liveRanges.map((A)=>[A.threadIndex,A])),V=B6($,Z),G=Y2(M,Z.path),U=G?B6(M,G):null;if(!V||!U)return M.document.comments;return M.document.comments.map((A,_)=>{if(!K.has(_))return A;let N=D.get(_),z=N?.resolution.match??null;if(!N||!z||z.containerId!==V.id)return A;let E=u7(z.startOffset,z.endOffset,J,X,Y.length);return{...A,anchor:S2(U,E.start,E.end),quote:k2(U,E.start,E.end)}})}function B6($,M){let Z=vQ($,M);if(!Z)return null;return{containerKind:Z,containerOrdinal:-1,id:M.semanticRegionId,text:M.text}}function vQ($,M){if($.tableCellIndex.has(M.id))return"tableCell";return m9(M.blockType)}function w5($,M){if(M.length===0)return[];let Z=P5($),J=Z.list();return M.map((X)=>({...X,cursorPoint:uQ(X,J,Z),viewport:null}))}function uQ($,M,Z){if(!$.cursor)return null;let J=hQ(M,$.cursor),X=IQ(J,$.cursor);if(X.length!==1)return null;let Y=X[0],Q=Z.resolveRuntimeContainer(Y.container.id);if(!Q)return null;return{offset:Math.max(0,Math.min(Y.offset,Q.text.length)),regionId:Q.id}}function hQ($,M){return M.kind?$.filter((Z)=>Z.containerKind===M.kind):$}function IQ($,M){if(M.prefix&&M.suffix)return gQ($,M.prefix,M.suffix);if(M.prefix)return h7($,M.prefix,"after");if(M.suffix)return h7($,M.suffix,"before");return[]}function h7($,M,Z){let J=[];for(let X of $)for(let Y of h0(X.text,M))J.push({container:X,offset:Z==="after"?Y+M.length:Y});return J}function gQ($,M,Z){let J=[];for(let X of $)for(let Y of o1(X.text,M,Z))J.push({container:X,offset:Y.startOffset});return J}var pQ=48;function x2($,M,Z){let J="documentIndex"in $?$.documentIndex:$;if(Z.length===0)return[];return Z.map((X)=>({...X,viewport:lQ(J,M,X)}))}function lQ($,M,Z){if(!Z.cursorPoint)return{status:"unresolved"};let J=g0(M.layout,$,Z.cursorPoint),X=J?{bottom:J.top+J.height,top:J.top}:M.estimateRegionBounds(Z.cursorPoint.regionId);if(!X)return{status:"unresolved"};return{scrollTop:dQ(M,X),status:xQ(M,X)}}function xQ($,M){let Z=$.viewport.top,J=Z+$.viewport.height;if(M.bottom<Z)return"above";if(M.top>J)return"below";return"visible"}function dQ($,M){let Z=Math.max(0,$.totalHeight-$.viewport.height),J=M.top-Math.min(pQ,$.viewport.height/4);return Math.max(0,Math.min(Z,J))}function P5($){let M=D5($.document),Z=new Map(M.map((X)=>[X.id,X])),J=new Map($.regions.map((X)=>[X.semanticRegionId,X]));return{findBySemanticMatch(X,Y){let Q=Z.get(X)??M[Y]??null;if(!Q)return null;return{runtimeContainer:J.get(Q.id)??null,semanticContainer:Q}},list(X){return X?M.filter((Y)=>Y.containerKind===X):M},resolveRuntimeContainer(X){return J.get(X)??null}}}var d2="",I7=1e6;function r2($,M,Z){return`${$}:${M}:${Z}`}function Q2($){let M=VK($),Z=T6(M.blocks.map((J,X)=>a2(J,X)));return j6(M,Z)}function a2($,M){let Z=[],J=[],X=[],Y=new Set,Q=0;function K(D,V,G,U,A=null){if(J.length>0)X.push(`
|
|
20
|
-
`),
|
|
21
|
-
${M.text}`:M.text}function YK($){return $.filter((M)=>M.regions.length>0).map((M)=>M.text).join(`
|
|
22
|
-
`)}function QK($,M){let Z=new Set;for(let J of $)for(let X of J.imageUrls)Z.add(X);return M&&DK(M,Z)?M:Z}function KK($,M){if(M.size===0)return $;let Z=null;for(let J of M){if($.has(J))continue;Z??=new Set($),Z.add(J)}return Z??$}function DK($,M){if($.size!==M.size)return!1;for(let Z of $)if(!M.has(Z))return!1;return!0}function p7($){let M=new Map;for(let[Z,J]of $.comments.entries()){let X=m2(J,$).match?.containerId??null;if(!X)continue;let Y=M.get(X)??[];Y.push(Z),M.set(X,Y)}return M}function qK($){let M=new Map;return c2(M,$),M}function c2($,M,Z=null){for(let J of M){if(J.type==="list"){for(let[X,Y]of J.items.entries())c2($,[Y],{index:X,ordered:J.ordered,start:J.start});continue}if(J.type==="listItem"){if(typeof J.checked==="boolean")$.set(J.id,{checked:J.checked,kind:"task"});else if(Z?.ordered)$.set(J.id,{kind:"ordered",label:`${(Z.start??1)+Z.index}.`});else $.set(J.id,{kind:"bullet",label:"•"});c2($,J.children,Z)}if(J.type==="blockquote")c2($,J.children,Z)}}function VK($){if($.blocks.length>0)return $;return a1([x({text:""})],$.comments,$.frontMatter)}function b6($,M=null){let Z=[],J=0,X=(Y)=>{let Q=J,K=Q+Y.text.length;Z.push({...Y,end:K,start:Q}),J=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
|
-
|
|
24
|
-
`.slice(M,Z);case"image":return d2.slice(M,Z);case"inlineCode":return $.code.slice(M,Z);case"link":return L6($.children,M,Z);case"text":return $.text.slice(M,Z);case"unsupported":return $.source.slice(M,Z)}}function R6($,M,Z,J){let X=FK($.children,M,Z,J);if(X===null)return null;let Y=z0(l7($.children,M,Z,J,X,`${$.path}.children`));return Y.length>0?O1($,Y,M,Z):null}function S6($,M,Z){let J=0,X=null,Y=(Q)=>{for(let K of Q){let q=H0(K),D=J,V=D+q;if(J=V,Z<=D||M>=V)continue;if(K.type==="text"){let G=Math.max(M,D);if(Math.min(Z,V)>G)X=X===null?new Set(K.marks):new Set(K.marks.filter((A)=>X?.has(A)));continue}if(K.type==="link"){let G=J;J=D,Y(K.children),J=G}}};return Y($.children),X?[...X]:[]}function FK($,M,Z,J){let X=0,Y=!1,Q=!0,K=(q)=>{for(let D of q){let V=H0(D),G=X,U=G+V;if(X=U,Z<=G||M>=U)continue;if(D.type==="text"){let A=Math.max(M,G);if(Math.min(Z,U)>A)Y=!0,Q&&=D.marks.includes(J);continue}if(D.type==="link"){let A=X;X=G,K(D.children),X=A}}};return K($),Y?Q:null}function l7($,M,Z,J,X,Y){let Q=[],K=0;for(let[q,D]of $.entries()){let V=K,G=H0(D),U=V+G,A=`${Y}.${q}`;if(K=U,Z<=V||M>=U){Q.push(D);continue}if(D.type==="text"){Q.push(...zK(D,Math.max(0,M-V),Math.min(G,Z-V),J,X,A));continue}if(D.type==="link"){let _=z0(l7(D.children,Math.max(0,M-V),Math.min(G,Z-V),J,X,`${A}.children`));if(_.length>0)Q.push({...D,children:_});continue}Q.push(D)}return Q}function zK($,M,Z,J,X,Y){let Q=$.text.slice(0,M),K=$.text.slice(M,Z),q=$.text.slice(Z),D=X?$.marks.filter((V)=>V!==J):HK($.marks,J);return[j1(Q,$.marks,`${Y}.before`),j1(K,D,`${Y}.selected`),j1(q,$.marks,`${Y}.after`)].filter(Boolean)}function HK($,M){return $.includes(M)?$:[...$,M].sort()}function k6($,M,Z){let J=EK($.children,M,Z,`${$.path}.children`);return J.length>0?O1($,J,M,Z):null}function EK($,M,Z,J){let X=x7($,M,Z);if(X){let Q=j1(X.code,[],`${J}.selected`);return i2($,M,Z,J,Q?[Q]:[])}let Y=L6($,M,Z);if(Y.length===0)return $;return i2($,M,Z,J,[C6(Y,`${J}.selected`)])}function x7($,M,Z){let J=0;for(let X of $){let Y=H0(X),Q=J,K=Q+Y;if(J=K,M===Q&&Z===K&&X.type==="inlineCode")return X;if(X.type==="link"){let q=x7(X.children,Math.max(0,M-Q),Math.min(Y,Z-Q));if(q)return q}}return null}function m6($,M,Z,J,X){return j5($,M,Z,J,(Y,Q,K)=>d7(Y,Q,K,X))}function d7($,M,Z,J){let X=z0(WK($.children,M,Z,J,`${$.path}.children`)??[]);return X.length>0?O1($,X,M,Z):null}function WK($,M,Z,J,X){let Y=[],Q=0,K=!1;for(let[q,D]of $.entries()){let V=`${X}.${q}`,G=H0(D),U=Q,A=U+G;if(Q=A,!K&&D.type==="link"&&M===U&&Z===A){if(J===null)Y.push(...D.children);else Y.push(r1({children:D.children,path:V,title:D.title,url:J}));K=!0;continue}Y.push(D)}return K?Y:null}function D2($,M){let Z=$.regionIndex.get(M);if(!Z)return null;let J=s1($.document.blocks,Z.blockId);if(!J)return null;return f6(J,Z.path,Z.semanticRegionId)}function yK($,M,Z,J,X){if(Z>=J)return null;let Y=D2($,M);return Y?X(Y,Z,J):null}function j5($,M,Z,J,X){let Y=yK($,M,Z,J,X);return Y?{kind:"replace-block",block:Y.block,blockId:Y.blockId,selection:Y.selection}:null}function f6($,M,Z){if($.type==="heading"||$.type==="paragraph")return{block:$,children:$.children,kind:"inlineBlock",path:M.replace(/\.children$/,"")};if($.type!=="table")return null;let J=/^(.*\.rows\.\d+\.cells\.\d+)$/.exec(M);if(!J)return null;for(let X of $.rows)for(let Y of X.cells)if(Y.id===Z)return{block:$,blockPath:J[1].replace(/\.rows\.\d+\.cells\.\d+$/,""),cell:Y,children:Y.children,kind:"tableCell",path:J[1]};return null}function c7($,M,Z){let J=s7($,M);if(!J)return null;return{kind:"replace-block",...s2(J.inlineRegion,J.startOffset,J.endOffset,Z)}}function a7($,M,Z){let J=s7($,M);if(!J)return null;return{kind:"replace-block",...i7(J.inlineRegion,J.startOffset,J.endOffset,Z)}}function i7($,M,Z,J){let X=`${$.path}.children`,Y=i2($.children,M,Z,X,J),Q=J.reduce((q,D)=>q+H0(D),0),K=M+Q;return O1($,Y,K,K)}function s2($,M,Z,J){let X=J(`${$.path}.children.selected`);return i7($,M,Z,[X])}function s7($,M){let Z=D2($,M.focus.regionId);if(!Z)return null;return{inlineRegion:Z,startOffset:Math.min(M.anchor.offset,M.focus.offset),endOffset:Math.max(M.anchor.offset,M.focus.offset)}}function O1($,M,Z,J){switch($.kind){case"inlineBlock":return{block:u0($.block,M),blockId:$.block.id,selection:r7(`${$.path}.children`,Z,J)};case"tableCell":{let X=J1({children:M,path:$.path}),Y=$.block.rows.map((Q)=>({...Q,cells:Q.cells.map((K)=>K.id===$.cell.id?X:K)}));return{block:w0($.block,Y),blockId:$.block.id,selection:r7($.path,Z,J)}}}}function r7($,M,Z){return{endOffset:Z,kind:"region-range-path",path:$,startOffset:M}}function q0($,M,Z=0){return{childIndices:M,kind:"descendant-primary-region",offset:Z,rootIndex:$}}function $0($,M=0){return{kind:"root-primary-region",offset:M,rootIndex:$}}function L1($,M,Z,J=0){return{cellIndex:Z,kind:"table-cell",offset:J,rootIndex:$,rowIndex:M}}function B0($,M){return $.regionIndex.get(M)??null}function Y2($,M){return $.regionPathIndex.get(M)??null}function V2($,M,Z,J){let X=$.tableCellRegionIndex.get(r2(M,Z,J));return X?$.regionIndex.get(X)??null:null}function BK($){return $.anchor.regionId===$.focus.regionId&&$.anchor.offset===$.focus.offset}function J0($,M){let Z="documentIndex"in $?$.documentIndex:$,J="documentIndex"in $?$.selection:M,X=BK(J),Y=o7(Z,J.anchor),Q=o7(Z,J.focus);if(Y<=Q)return{collapsed:X,end:J.focus,start:J.anchor};return{collapsed:X,end:J.anchor,start:J.focus}}function o2($,M){if(!M)return null;if("kind"in M){if(M.kind==="root-primary-region"){let J=$.document.blocks[M.rootIndex],X=J?v6($,J):null;return X?q2(X.id,O5(X.text,M.offset)):null}if(M.kind==="descendant-primary-region"){let J=$.document.blocks[M.rootIndex],X=J?PK(J,M.childIndices):null,Y=X?v6($,X):null;return Y?q2(Y.id,O5(Y.text,M.offset)):null}if(M.kind==="table-cell"){let J=$.document.blocks[M.rootIndex];if(!J||J.type!=="table")return null;let X=V2($,J.id,M.rowIndex,M.cellIndex);return X?q2(X.id,O5(X.text,M.offset)):null}let Z=Y2($,M.path);if(!Z)return null;if(M.kind==="region-path")return q2(Z.id,O5(Z.text,M.offset));return{anchor:{regionId:Z.id,offset:Math.max(0,Math.min(M.startOffset,Z.text.length))},focus:{regionId:Z.id,offset:Math.max(0,Math.min(M.endOffset,Z.text.length))}}}return M}function o7($,M){let Z=$.regionOrderIndex.get(M.regionId);if(Z===void 0)throw Error(`Unknown canvas region: ${M.regionId}`);return Z*I7+M.offset}function q2($,M){let Z={offset:M,regionId:$};return{anchor:Z,focus:Z}}function O5($,M){return M==="end"?$.length:Math.max(0,Math.min(M,$.length))}function PK($,M){let Z=$;for(let J of M){if(!Z)return null;let X=A0(Z);if(!X)return null;Z=X[J]??null}return Z}function v6($,M){let Z=$.blockIndex.get(M.id);if(!Z)return null;let J=Z.regionIds[0];if(J)return $.regionIndex.get(J)??null;let X=A0(M);if(!X)return null;for(let Y of X){let Q=v6($,Y);if(Q)return Q}return null}function n2($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,Z=M?$.documentIndex.blockIndex.get(M.blockId)??null:null,J=$.selection.anchor.offset,X=M?.inlines.find((Y)=>J>Y.start&&J<Y.end)??M?.inlines.find((Y)=>Y.end===J)??M?.inlines.find((Y)=>Y.start===J)??null;return{block:Z?{blockId:Z.id,depth:Z.depth,nodeType:Z.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 L5($){let M=$.documentIndex.regionIndex.get($.selection.anchor.regionId)??null,Z=$.selection.anchor.offset,J=M?.inlines.find((X)=>Z>X.start&&Z<X.end)??M?.inlines.find((X)=>X.end===Z)??M?.inlines.find((X)=>X.start===Z)??null;return J?.kind==="image"?J:null}function C5($){let M=J0($.documentIndex,$.selection);if(M.start.regionId!==M.end.regionId||M.start.offset===M.end.offset)return[];let Z=$.documentIndex.regionIndex.get(M.start.regionId);if(!Z)return[];let J=s1($.documentIndex.document.blocks,Z.blockId);if(!J)return[];let X=f6(J,Z.path,Z.semanticRegionId);return X?S6(X,M.start.offset,M.end.offset):[]}var u6=new Map([["rgba(0, 0, 0, 0)",[0,0,0,0]]]);function t2($){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 I6($,M){let Z=M??bK();return $.animations.some((J)=>Z-J.startedAt<t2(J))}function t7($,M){return g6($,M,"inserted-text-highlight",(Z)=>Z.regionPath)}function e7($,M){return q$($,M,"active-block-flash",(Z)=>Z.blockPath)}function $$($,M){return g6($,M,"deleted-text-fade",(Z)=>Z.regionPath)}function M$($,M){return g6($,M,"punctuation-pulse",(Z)=>Z.regionPath)}function Z$($,M){return q$($,M,"list-marker-pop",(Z)=>Z.blockPath)}function J$($,M,Z){let J=new Set([$,M]);for(let X of Z){if(X.endOffset<=$||X.startOffset>=M)continue;J.add(Math.max($,X.startOffset)),J.add(Math.min(M,X.endOffset))}return[...J].sort((X,Y)=>X-Y)}function X$($,M,Z){return $.find((J)=>J.startOffset<Z&&J.endOffset>M)??null}function Y$($,M,Z){if(!M)return $;return $4(Z.insertHighlightText,$,M.progress)}function Q$($,M){return $4($,"rgba(0, 0, 0, 0)",M.progress)}function S5($,M){return $4($,"rgba(0, 0, 0, 0)",M.progress)}function K$($,M){return $4(M.insertHighlightText,"rgba(0, 0, 0, 0)",$.progress)}function D$($){let M=Math.min(1,$.progress*2);return 0.1+0.9*wK(M)}function e2($,M,Z){let J=Math.max(0,M.progress*2-1);return $4(Z.insertHighlightText,$,J)}function g6($,M,Z,J){let X=new Map;for(let Y of $.animations){if(Y.kind!==Z)continue;let Q=t2(Y),K=M-Y.startedAt;if(K>=Q)continue;let q={...Y,progress:Math.max(0,Math.min(1,K/Q))},D=J(Y),V=X.get(D);if(V)V.push(q);else X.set(D,[q])}return X}function q$($,M,Z,J){let X=new Map;for(let Y of $.animations){if(Y.kind!==Z)continue;let Q=t2(Y),K=M-Y.startedAt;if(K>=Q)continue;X.set(J(Y),{...Y,progress:Math.max(0,Math.min(1,K/Q))})}return X}function wK($){return 1-(1-$)*(1-$)*(1-$)}function $4($,M,Z){let J=n7($),X=n7(M);return`rgba(${h6(R5(J[0],X[0],Z))}, ${h6(R5(J[1],X[1],Z))}, ${h6(R5(J[2],X[2],Z))}, ${R5(J[3],X[3],Z)})`}function bK(){return typeof performance<"u"?performance.now():Date.now()}function n7($){let M=u6.get($);if(M)return M;let Z=TK($)??jK($)??OK($)??u6.get("rgba(0, 0, 0, 0)");return u6.set($,Z),Z}function TK($){let M=$.trim();if(!M.startsWith("#"))return null;let Z=M.slice(1);if(Z.length===3)return[Number.parseInt(`${Z[0]}${Z[0]}`,16),Number.parseInt(`${Z[1]}${Z[1]}`,16),Number.parseInt(`${Z[2]}${Z[2]}`,16),1];if(Z.length===6)return[Number.parseInt(Z.slice(0,2),16),Number.parseInt(Z.slice(2,4),16),Number.parseInt(Z.slice(4,6),16),1];return null}function jK($){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 OK($){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 R5($,M,Z){return $+(M-$)*Z}function h6($){return Math.round($)}function k5($,M,Z=C1()){if(M<=0)return $;let J=f5($);if(!J)return $;let X=$.selection.focus.offset,Y=Math.max(0,X-M);if(X<=Y)return $;return M4($,{endOffset:X,kind:"inserted-text-highlight",regionPath:J.path,startOffset:Y,startedAt:Z})}function V$($,M,Z,J){let X=f5($);if(!X)return M;let Y=X.text.slice(Z,J);if(Y.length===0)return M;if(!X.inlines.some((K)=>K.start<=Z&&K.end>=J&&K.kind==="text"&&K.link===null&&K.marks.length===0))return M;return M4(M,{kind:"deleted-text-fade",regionPath:X.path,startOffset:Z,startedAt:C1(),text:Y})}function U$($,M=C1()){let Z=f5($),J=$.selection.focus.offset-1;if(!Z||J<0||Z.text[J]!==".")return $;return M4($,{kind:"punctuation-pulse",offset:J,regionPath:Z.path,startedAt:M})}function G$($,M,Z=C1()){return M4($,{blockPath:M,kind:"list-marker-pop",startedAt:Z})}function A$($,M,Z=C1()){return M4($,{blockPath:M,kind:"active-block-flash",startedAt:Z})}function p6($,M){return $.filter((Z)=>Z.startedAt+t2(Z)>M)}function C1(){return typeof performance<"u"?performance.now():Date.now()}function m5($,M){let Z=Math.max(-1/0,...$.animations.map((J)=>J.startedAt));return M.animations.some((J)=>J.startedAt>Z)}function N$($){let M=f5($);return(M?$.documentIndex.blockIndex.get(M.blockId)??null:null)?.path??""}function f5($){return $.documentIndex.regionIndex.get($.selection.focus.regionId)??null}function M4($,M){let Z=p6($.animations,M.startedAt);return{...$,animations:[...Z,M]}}function U2($,M,Z,J){return x6(G2($.inlines,M,Z,J))}function G2($,M,Z,J){let Y=LK($,M,Z,{didInsert:!1,generatedRunCount:0,replacementText:J});return mK(fK(Y))}function x6($){let M=[];for(let Z=0;Z<$.length;Z+=1){let J=$[Z];if(J.link){let Y=[],Q=J.link;while(Z<$.length&&d6($[Z].link,Q)){let K=F$($[Z]);if(K)Y.push(K);Z+=1}if(Z-=1,Y.length>0)M.push(r1({children:z0(Y),title:Q.title,url:Q.url}));continue}let X=F$(J);if(X)M.push(X)}return z0(M)}function LK($,M,Z,J){let X=[];for(let[Y,Q]of $.entries()){if(!J.didInsert&&M===Z&&M===Q.start)l6(X,J,_$($[Y-1]??null,Q));if(Z<=Q.start||M>=Q.end){X.push(v5(Q));continue}let K=Math.max(0,M-Q.start),q=Math.min(Q.text.length,Z-Q.start),D=!J.didInsert&&J.replacementText.length>0?J.replacementText:"",V=CK(Q,K,q,D,J);if(K!==q||D.length>0)J.didInsert=!0;X.push(...V)}if(!J.didInsert)l6(X,J,_$($.at(-1)??null,null));return X}function CK($,M,Z,J,X){switch($.kind){case"text":case"inlineCode":case"unsupported":return RK($,M,Z,J);case"break":return SK($,M,Z,J,X);case"image":return kK($,M,Z,J)}}function RK($,M,Z,J){let X=$.text.slice(0,M)+J+$.text.slice(Z);return X.length>0?[{...v5($),text:X}]:[]}function SK($,M,Z,J,X){if(M===Z)return[v5($)];let Y=[];if(J.length>0)l6(Y,X,$.link);return Y}function kK($,M,Z,J){if(M===0&&Z===$.text.length)return J.length>0?[z$(J,$.link,0)]:[];return[v5($)]}function l6($,M,Z){if(M.replacementText.length===0){M.didInsert=!0;return}$.push(z$(M.replacementText,Z,M.generatedRunCount)),M.generatedRunCount+=1,M.didInsert=!0}function z$($,M,Z){return{id:`generated:${Z}`,image:null,inlineCode:!1,kind:"text",link:M,marks:[],originalType:null,text:$}}function _$($,M){return $?.link&&M?.link&&d6($.link,M.link)?$.link:null}function v5($){return{id:$.id,image:$.image,inlineCode:$.inlineCode,kind:$.kind,link:$.link,marks:$.marks,originalType:$.originalType,text:$.text}}function mK($){let M=[],Z=0;for(let J of $){let X=Z,Y=X+J.text.length;M.push({...J,end:Y,start:X}),Z=Y}return M}function fK($){let M=[];for(let Z of $){let J=M.at(-1);if(J&&vK(J,Z)){M[M.length-1]={...J,text:J.text+Z.text};continue}M.push(Z)}return M}function vK($,M){return $.kind===M.kind&&$.inlineCode===M.inlineCode&&d6($.link,M.link)&&hK($.image,M.image)&&$.originalType===M.originalType&&$.marks.join(",")===M.marks.join(",")}function F$($){switch($.kind){case"break":return M5();case"image":return $.image?uK($.image):null;case"inlineCode":return d1({code:$.text});case"text":return $.text.length>0?i0({marks:$.marks,text:$.text}):null;case"unsupported":return Z5({originalType:$.originalType??"unsupported",source:$.text})}}function uK($){return E1({alt:$.alt,title:$.title,url:$.url,width:$.width})}function d6($,M){return $?.url===M?.url&&$?.title===M?.title}function hK($,M){return $?.url===M?.url&&$?.title===M?.title&&$?.alt===M?.alt&&$?.width===M?.width}function y$($,M,Z){let J=[],X=0,Y={childIndices:[],offset:0},Q="",K=$!==null;if($)J.push($),Y=H$($);let q=0;if($&&M.length>0){let D=M[0];if(u5($)&&D.type==="paragraph"){let V=r6($,$.children,D.children);J[J.length-1]=V,Y={childIndices:[],offset:V.plainText.length},q=1,Q=D.plainText}else if(E$($,D)){let V=W$($,D);J[J.length-1]=V,Y=B$(V),q=1}}for(let D=q;D<M.length;D+=1){let V=M[D];J.push(V),X=J.length-1,Y=H$(V)}if(Z){let D=J.length-1,V=J[D]??null,G=q>=M.length&&$!==null,U=null;if(V){if(!G&&V.type==="paragraph"&&u5(Z)){if(U=r6(Z,V.children,Z.children),$===null&&M.length===1)K=!0,Q=V.plainText}else if(G&&u5(V)&&u5(Z))U=r6(V,V.children,Z.children);else if(E$(V,Z))U=W$(V,Z),Y={childIndices:[A0(V).length-1],offset:"end"}}else if($===null&&M.length===0)K=!0;if(U)J[D]=U;else J.push(Z)}return{blocks:J,caretLocalIndex:X,caretChildIndices:Y.childIndices,caretOffset:Y.offset,startRegionInsertedText:Q,startRegionPreservedAtRoot0:K}}function Z4($,M,Z){if($.type==="table")return null;if($.id===M.blockId)return IK($,M,Z);return P$($,(J)=>pK(J,M,Z))}function J4($,M,Z){if($.type==="table")return null;if($.id===M.blockId)return gK($,M,Z);return P$($,(J)=>lK(J,M,Z))}function R1($,M){if($.id===M.blockId)return!0;let Z=A0($);return Z!==null&&Z.some((J)=>R1(J,M))}function H$($){return A0($)?B$($):{childIndices:[],offset:$.plainText.length}}function B$($){return{childIndices:[A0($).length-1],offset:"end"}}function r6($,M,Z){return u0($,z0([...M,...Z]))}function u5($){return $!==null&&($.type==="heading"||$.type==="paragraph")}function E$($,M){return $.type===M.type&&A0($)!==null}function W$($,M){let Z=A0($),J=A0(M);return w1($,[...Z,...J])}function IK($,M,Z){if(Z===0)return null;switch($.type){case"heading":case"paragraph":return u0($,U2(M,Z,M.text.length,""));case"code":return L2($,M.text.slice(0,Z));case"unsupported":return C2($,M.text.slice(0,Z));default:return null}}function gK($,M,Z){if(Z===M.text.length)return null;switch($.type){case"heading":case"paragraph":return u0($,U2(M,0,Z,""));case"code":return L2($,M.text.slice(Z));case"unsupported":return C2($,M.text.slice(Z));default:return null}}function P$($,M){let Z=A0($);return Z?w1($,M(Z)):null}function pK($,M,Z){let J=$.findIndex((Q)=>R1(Q,M));if(J===-1)return[];let X=$.slice(0,J),Y=Z4($[J],M,Z);return Y?[...X,Y]:X}function lK($,M,Z){let J=$.findIndex((Q)=>R1(Q,M));if(J===-1)return[];let X=$.slice(J+1),Y=J4($[J],M,Z);return Y?[Y,...X]:X}function b$($,M,Z){let J=J0($,M);if(J.start.regionId===J.end.regionId)return xK($,J,Z);let X=Z.length>0?[x({text:Z})]:[];return c6($,M,X)}function c6($,M,Z){let J=J0($,M),X=B0($,J.start.regionId),Y=B0($,J.end.regionId);if(!X||!Y)throw Error("Unknown selection endpoints.");let Q=$.document.blocks[X.rootIndex],K=$.document.blocks[Y.rootIndex];if(!Q||!K)throw Error("Unknown root blocks for selection.");let q=Z4(Q,X,J.start.offset),D=J4(K,Y,J.end.offset),V=y$(q,Z,D),G=V.blocks.length>0?V.blocks:[x({text:""})],U=X.rootIndex,A=Y.rootIndex-X.rootIndex+1,_=P1($.document,U,A,G),N=K2($,_,U,A),z=X===Y?J.end.offset:X.text.length;return{documentIndex:V.startRegionPreservedAtRoot0?T$($,N,X,J.start.offset,z,V.startRegionInsertedText):N,selection:q0(U+V.caretLocalIndex,V.caretChildIndices,V.caretOffset)}}function xK($,M,Z){let J=B0($,M.start.regionId);if(!J)throw Error(`Unknown region: ${M.start.regionId}`);let X=T5($,J.blockId,(q)=>dK(q,J,M.start.offset,M.end.offset,Z));if(!X)throw Error(`Failed to replace block for region: ${J.id}`);let Y=K2($,X,J.rootIndex,1),Q=T$($,Y,J,M.start.offset,M.end.offset,Z),K=Y2(Q,J.path);if(!K)throw Error(`Failed to remap region after replacement: ${J.path}`);return{documentIndex:Q,selection:q2(K.id,M.start.offset+Z.length)}}function dK($,M,Z,J,X){switch($.type){case"heading":case"paragraph":return u0($,U2(M,Z,J,X));case"code":return L2($,w$(M,Z,J,X));case"table":return rK($,M,Z,J,X);case"unsupported":return C2($,w$(M,Z,J,X));default:throw Error(`Region text replacement is not supported for block type: ${$.type}`)}}function rK($,M,Z,J,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=U2(M,Z,J,X),q=$.rows.map((D,V)=>{if(V!==Y)return D;let G=D.cells.map((U,A)=>A===Q?J1({children:K}):U);return{...D,cells:G}});return w0($,q)}function w$($,M,Z,J){return G2($.inlines,M,Z,J).map((X)=>X.text).join("")}function T$($,M,Z,J,X,Y){if($.document.comments.length===0)return M;let Q=w6($,M,Z,J,X,Y);return Q===M.document.comments?M:b5(M,{...M.document,comments:Q})}function Y4($){let M=Q2($),Z=C$(M);return{animations:[],documentIndex:M,future:[],history:[],selection:{anchor:Z,focus:Z}}}function l0($){let M=C0($.documentIndex);return a1(R2($.documentIndex.document.blocks),M.threads,$.documentIndex.document.frontMatter)}function d($,M){if(!M)return null;switch(M.kind){case"keep-state":return $;case"set-selection":return Q0($,M.selection);case"replace-block":{let Z=T5($.documentIndex,M.blockId,()=>M.block);return Z?X4($,Q2(Z),M.selection??null):null}case"splice-blocks":{let Z=P1($.documentIndex.document,M.rootIndex,M.count??1,M.blocks);return X4($,Q2(Z),M.selection??null)}case"splice-text":{let Z=b$($.documentIndex,M.selection,M.text);return X4($,Z.documentIndex,Z.selection)}case"splice-fragment":{let Z=c6($.documentIndex,M.selection,M.fragment);return X4($,Z.documentIndex,Z.selection)}case"splice-comments":{let Z=T9($.documentIndex.document,M.index,M.count,M.threads);return X4($,b5($.documentIndex,Z),null)}}}function X4($,M,Z){let J=cK($,M),X=o2(J.documentIndex,Z)??$.selection,Y=R$($,J,X);return Q0(J,X,Y)}function Q0($,M,Z){let J="regionId"in M?{anchor:h5($.documentIndex,M),focus:h5($.documentIndex,M)}:{anchor:h5($.documentIndex,M.anchor),focus:h5($.documentIndex,M.focus)},X={...$,selection:J};return Z??R$($,X)?A$(X,N$(X)):X}function E0($,M,Z,J){let X={regionId:M,offset:Z};return Q0($,J?{anchor:$.selection.anchor,focus:X}:X)}function cK($,M){let Z=C$(M);return{animations:p6($.animations,C1()),documentIndex:M,future:[],history:[...$.history,{document:$.documentIndex.document,selection:$.selection}],selection:{anchor:Z,focus:Z}}}function a6($){let M=$.history.at(-1);if(!M)return $;return L$(M,{future:[O$($),...$.future],history:$.history.slice(0,-1)})}function i6($){let M=$.future[0];if(!M)return $;return L$(M,{future:$.future.slice(1),history:[...$.history,O$($)]})}function O$($){return{document:$.documentIndex.document,selection:$.selection}}function L$($,M){return{animations:[],documentIndex:Q2($.document),future:M.future,history:M.history,selection:$.selection}}function C$($){return $.regions[0]?{regionId:$.regions[0].id,offset:0}:{regionId:"empty",offset:0}}function h5($,M){let Z=B0($,M.regionId);if(!Z)return M;return{regionId:Z.id,offset:Math.max(0,Math.min(M.offset,Z.text.length))}}function R$($,M,Z){let J=j$($.documentIndex,$.selection),X=j$(M.documentIndex,Z??M.selection);return X!==null&&X!==J}function j$($,M){let Z=$.regionIndex.get(M.focus.regionId),J=Z?$.blockIndex.get(Z.blockId)??null:null;if(!Z||!J?.path)return null;return J.type==="table"?`cell:${Z.path}`:`block:${J.path}`}function D4($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return{kind:"unsupported"};if(Z.blockType==="code"){let K=$.blockIndex.get(Z.blockId);return K?{kind:"code",region:Z,rootIndex:K.rootIndex}:{kind:"unsupported"}}let J=o6($,Z.id);if(J)return{kind:"tableCell",...J};let X=N2($,M);if(X)return{kind:"listItem",...X};let Y=aK($,M);if(Y)return{kind:"blockquoteTextBlock",...Y};let Q=A2($,M);if(Q)return{kind:"rootTextBlock",...Q};return{kind:"unsupported"}}function q4($,M){let Z=$.blockIndex.get(M);if(!Z)throw Error(`Unknown root block: ${M}`);return Z.rootIndex}function s6($,M,Z){let J=M?$.blockIndex.get(M)??null:null;while(J){if(J.type===Z)return J;let X=J.parentBlockId;J=X?$.blockIndex.get(X)??null:null}return null}function Q4($){let M=$.split("."),Z=[];for(let J=0;J<M.length-1;J+=1)if(M[J]==="children"){let X=Number(M[J+1]);if(Number.isInteger(X))Z.push(X)}return Z}function A2($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let J=$.blockIndex.get(Z.blockId);if(!J)return null;let X=J.rootIndex,Y=$.document.blocks[X];if(!Y||Y.type!=="heading"&&Y.type!=="paragraph")return null;return{block:Y,region:Z,rootIndex:X}}function aK($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let J=$.blockIndex.get(Z.blockId),X=s6($,J?.id??null,"blockquote");if(!J||!X||J.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===J.id),q=Q.children[K];if(!q||q.type!=="heading"&&q.type!=="paragraph")return null;return{block:q,blockChildIndices:Q4(J.path),childIndex:K,region:Z,quote:Q,rootIndex:Y}}function K4($,M){return s1($.document.blocks,M)}function N2($,M){let Z=$.regionIndex.get(M.anchor.regionId);if(!Z)return null;let J=$.blockIndex.get(Z.blockId),X=s6($,J?.id??null,"listItem"),Y=s6($,J?.id??null,"list");if(!J||!X||!Y)return null;let Q=K4($,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,V=D?.parentBlockId?$.blockIndex.get(D.parentBlockId)??null:null,G=D?.type==="listItem"?K4($,D.id):null,U=V?.type==="list"?K4($,V.id):null,A=U?.type==="list"&&G?U.items.findIndex((_)=>_.id===G.id):-1;return{region:Z,item:q,itemChildIndices:Q4(X.path),itemIndex:K,list:Q,listChildIndices:Q4(Y.path),parentItem:G?.type==="listItem"?G:null,parentItemChildIndices:D?.type==="listItem"?Q4(D.path):null,parentItemIndex:A>=0?A:null,parentList:U?.type==="list"?U:null,parentListChildIndices:V?.type==="list"?Q4(V.path):null,rootIndex:Y.rootIndex}}function o6($,M){let Z=$.regionIndex.get(M);if(!Z)return null;let J=$.tableCellIndex.get(Z.id),X=$.blockIndex.get(Z.blockId),Y=X?.type==="table"?$.document.blocks[X.rootIndex]:null;if(!J||!X||!Y||Y.type!=="table")return null;return{cellIndex:J.cellIndex,rootIndex:X.rootIndex,rowIndex:J.rowIndex,table:Y}}function V4($,M,Z){return s0({checked:M,children:[x({text:$})],spread:Z})}function _2($,M){let Z=$.children[0];if(!Z||Z.type!=="paragraph")return null;return j0($,[x({text:M}),...$.children.slice(1)])}function S$($,M){return M.reduce((Z,J)=>`${Z}.children.${J}`,`root.${$}`)}function k$($,M){if($.selection.anchor.regionId!==$.selection.focus.regionId||$.selection.anchor.offset!==$.selection.focus.offset)return null;let Z=B0($.documentIndex,$.selection.focus.regionId);if(!Z)return null;if(M==="forward"&&$.selection.focus.offset>=Z.text.length)return null;let J=M==="backward"?iK(Z.text,$.selection.focus.offset):$.selection.focus.offset,X=M==="backward"?$.selection.focus.offset:sK(Z.text,$.selection.focus.offset);if(J===X)return null;return{action:{kind:"splice-text",selection:{anchor:{regionId:Z.id,offset:J},focus:{regionId:Z.id,offset:X}},text:""},startOffset:J,endOffset:X}}function iK($,M){let Z=Array.from($.slice(0,M));if(Z.length===0)return 0;return M-Z.at(-1).length}function sK($,M){let Z=Array.from($.slice(M))[0];return Z?M+Z.length:$.length}function m$($,M,Z){let J=$.regionIndex.get(M.anchor.regionId);if(!J)return null;let X=J0($,M),Y=X.start.regionId===X.end.regionId&&X.start.regionId===J.id?J.text.slice(0,X.start.offset)+Z+J.text.slice(X.end.offset):Z;return oK($,M,J.id,Y)??tK($,M,J.id,Y)??nK($,M,J.id,Y)??eK($,M,J.id,Y)??ZD($,J.blockId,J.rootIndex,Y)??{kind:"splice-text",selection:M,text:Z}}function oK($,M,Z,J){let X=N2($,M),Y=YD(J);if(!X||!Y||X.region.id!==Z)return null;let Q=_2(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:q0(X.rootIndex,[...X.listChildIndices,X.itemIndex,0])}}function nK($,M,Z,J){if(!t6($,M,Z))return null;if(/^\s*([-+*])\s\[( |x|X)\]\s$/.exec(J)){let Q=J.toLowerCase().includes("[x]");return n6($,M,{checked:Q,ordered:!1,start:null})}if(/^\s*[-+*]\s$/.test(J))return n6($,M,{checked:null,ordered:!1,start:null});let Y=/^\s*(\d+)\.\s$/.exec(J);if(Y)return n6($,M,{checked:null,ordered:!0,start:Number(Y[1])});return null}function tK($,M,Z,J){let X=A2($,M),Y=QD(J);if(!X||X.region.id!==Z||X.block.type!=="heading"||!Y)return null;return{kind:"splice-blocks",blocks:[Z1({depth:Y.depth,text:Y.text})],rootIndex:X.rootIndex,selection:$0(X.rootIndex)}}function eK($,M,Z,J){return $D($,M,Z,J)??MD($,M,Z,J)}function $D($,M,Z,J){if(!t6($,M,Z))return null;let X=/^(#{1,6})\s$/.exec(J);if(!X)return null;return JD($,M,X[1].length)}function MD($,M,Z,J){if(!t6($,M,Z)||!/^>\s$/.test(J))return null;return XD($,M)}function ZD($,M,Z,J){if(!/^(?:(?:-\s?){3}|(?:\*\s?){3}|(?:_\s?){3})$/.test(J))return null;return{kind:"splice-blocks",blocks:[J5(),x({text:""})],rootIndex:q4($,M),selection:$0(Z+1)}}function n6($,M,Z){let J=q4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[W1({items:[s0({checked:Z.checked,children:[x({text:""})],spread:!1})],ordered:Z.ordered,spread:!1,start:Z.start})],rootIndex:J,selection:q0(J,[0,0])}}function JD($,M,Z){let J=q4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[Z1({depth:Z,text:""})],rootIndex:J,selection:$0(J)}}function XD($,M){let Z=q4($,$.regionIndex.get(M.anchor.regionId).blockId);return{kind:"splice-blocks",blocks:[W0({children:[x({text:""})]})],rootIndex:Z,selection:q0(Z,[0])}}function t6($,M,Z){let J=A2($,M);return J?.region.id===Z&&J.block.type==="paragraph"}function YD($){let M=/^[-+*]\s(.+)$/.exec($);if(M)return{ordered:!1,text:M[1]};let Z=/^\d+\.\s(.+)$/.exec($);if(Z)return{ordered:!0,text:Z[1]};return null}function QD($){let M=/^(#{1,6})\s(.+)$/.exec($);return M?{depth:M[1].length,text:M[2]}:null}function v$($,M){let Z=J0($,M);if(Z.collapsed)return null;let J=B0($,Z.start.regionId),X=B0($,Z.end.regionId);if(!J||!X)return null;let Y=$.document.blocks[J.rootIndex],Q=$.document.blocks[X.rootIndex];if(!Y||!Q)return null;if(J===X)return{kind:"single-region",normalized:Z,region:J,root:Y,wholeRegion:Z.start.offset===0&&Z.end.offset===J.text.length};return{kind:"multi-region",normalized:Z,startRegion:J,endRegion:X,sameRoot:J.rootIndex===X.rootIndex,startRoot:Y,endRoot:Q}}function I5($,M){let Z=J0($,M),J=B0($,Z.start.regionId),X=B0($,Z.end.regionId);if(!J||!X)return null;let Y=f$(J)||f$(X);return{normalized:Z,sameRegion:J===X,startRegion:J,endRegion:X,structuralBlocked:Y,prefersVerbatimFallback:J.blockType==="code"||X.blockType==="code"}}function f$($){return $.blockType==="table"||$.blockType==="code"}function e6($,M){let Z=v$($,M);if(!Z)return null;switch(Z.kind){case"single-region":if(!Z.wholeRegion||Z.region.blockType==="table"){let X=DD(Z.region,Z.normalized.start.offset,Z.normalized.end.offset);return KD(X)}let J=h$(Z.root,Z.region);return J?u$([J]):null;case"multi-region":{let X=Z.sameRoot?qD($,Z.startRoot,Z.startRegion,Z.normalized.start.offset,Z.endRegion,Z.normalized.end.offset):GD($,Z.startRegion,Z.normalized.start.offset,Z.endRegion,Z.normalized.end.offset);return X.length>0?u$(X):null}}}function KD($){if($.length===0)return null;if(O8($))return{kind:"text",text:X0($)};return{kind:"inlines",inlines:$}}function u$($){if(K5($))return{kind:"text",text:$[0].plainText};return{kind:"blocks",blocks:$}}function h$($,M){if($.id===M.blockId)return $;let Z=A0($);if(!Z)return null;let J=Z.find((Y)=>R1(Y,M)),X=J?h$(J,M):null;return X?w1($,[X]):null}function DD($,M,Z){let J=G2($.inlines,Z,$.text.length,""),X=G2(J,0,M,"");return x6(X)}function qD($,M,Z,J,X,Y){if(M.type==="table")return UD($,M,Z,J,X,Y);let Q=I$(M,Z,J,X,Y);return Q?[Q]:[]}function VD($,M,Z,J,X){let Y=$.roots[M.rootIndex],Q=Y?.regions[0],K=Y?.regions.at(-1);return M===Q&&J===K&&Z===0&&X===K.text.length}function UD($,M,Z,J,X,Y){if(VD($,Z,J,X,Y))return[M];let Q=Z.tableCellPosition?.rowIndex,K=Z.tableCellPosition?.cellIndex,q=X.tableCellPosition?.rowIndex,D=X.tableCellPosition?.cellIndex;if(Q===void 0||K===void 0||q===void 0||D===void 0)return[];if(Q!==0||K!==0||J!==0)return[];let V=M.rows[q];if(!V)return[];let G=V.cells.length-1;if(D!==G||Y!==X.text.length)return[];return[w0(M,M.rows.slice(0,q+1))]}function I$($,M,Z,J,X){let Y=A0($);if(!Y)return null;let Q=Y.findIndex((q)=>R1(q,M)),K=Y.findIndex((q)=>R1(q,J));if(Q===-1||K===-1)return null;if(Q===K){let q=I$(Y[Q],M,Z,J,X);return q?w1($,[q]):null}return w1($,g$(Y,Q,M,Z,K,J,X))}function GD($,M,Z,J,X){return g$($.document.blocks,M.rootIndex,M,Z,J.rootIndex,J,X)}function g$($,M,Z,J,X,Y,Q){let K=J4($[M],Z,J),q=$.slice(M+1,X),D=Z4($[X],Y,Q);return[K,...q,D].filter((V)=>V!==null)}function $3($,M){let Z=I5($.documentIndex,$.selection);if(!Z)return null;switch(M.kind){case"text":return M.text.length>0?d($,{kind:"splice-text",selection:$.selection,text:M.text}):null;case"inlines":{if(M.inlines.length===0)return null;if(Z.sameRegion){let J=a7($.documentIndex,$.selection,M.inlines);if(J)return d($,J)}if(Z.structuralBlocked)return null;return d($,{kind:"splice-fragment",fragment:[H1({children:M.inlines})],selection:$.selection})}case"blocks":if(M.blocks.length===0||Z.structuralBlocked)return null;return d($,{kind:"splice-fragment",fragment:M.blocks,selection:$.selection})}}function q1($,M,Z,J=0){return q0($,[...M,Z,0],J)}function M3($,M){let Z=$.region.text,J=$.item,X=typeof J.checked==="boolean"?!1:J.checked;if(M===0){let D=V4("",X,J.spread);return{kind:"replace-block",block:e($.list,[...$.list.items.slice(0,$.itemIndex),D,J,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:g5(D,$.rootIndex,[...$.listChildIndices,$.itemIndex]),selection:q1($.rootIndex,$.listChildIndices,$.itemIndex)}}if(M===Z.length){let D=V4("",X,J.spread);return{kind:"replace-block",block:e($.list,[...$.list.items.slice(0,$.itemIndex+1),D,...$.list.items.slice($.itemIndex+1)]),blockId:$.list.id,listItemInsertedPath:g5(D,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:q1($.rootIndex,$.listChildIndices,$.itemIndex+1)}}let Y=Z.slice(0,M),Q=Z.slice(M),K=V4(Q,X,J.spread),q=j0(J,[x({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:g5(K,$.rootIndex,[...$.listChildIndices,$.itemIndex+1]),selection:q1($.rootIndex,$.listChildIndices,$.itemIndex+1)}}function p$($,M){if(M!==0||$.region.text.length!==0)return M3($,M);if($.parentItem&&$.parentItemIndex!==null&&$.parentItemChildIndices&&$.parentList&&$.parentListChildIndices)return AD($);let Z=$.list.items.slice(0,$.itemIndex),J=$.list.items.slice($.itemIndex+1),X=[];if(Z.length>0)X.push(e($.list,Z));if(X.push(x({text:""})),J.length>0)X.push(e($.list,J));return{kind:"splice-blocks",blocks:X,rootIndex:$.rootIndex,selection:$0($.rootIndex+(Z.length>0?1:0))}}function l$($){if(typeof $.item.checked==="boolean"){let M=s0({checked:null,children:$.item.children,spread:$.item.spread});return{kind:"replace-block",block:e($.list,$.list.items.map((Z,J)=>J===$.itemIndex?M:Z)),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((J,X)=>X!==$.itemIndex)),blockId:$.list.id,selection:q1($.rootIndex,$.listChildIndices,$.itemIndex-1,"end")};let Z=_2(M,`${M.plainText}${$.item.plainText}`);if(!Z)return null;return{kind:"replace-block",block:e($.list,$.list.items.flatMap((J,X)=>{if(X===$.itemIndex-1)return[Z];if(X===$.itemIndex)return[];return[J]})),blockId:$.list.id,selection:q1($.rootIndex,$.listChildIndices,$.itemIndex-1,M.plainText.length)}}return{kind:"splice-blocks",blocks:[x({text:$.item.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function x$($){if($.itemIndex===0)return null;let M=$.list.items[$.itemIndex-1];if(!M)return null;let Z=ND(M,$.item,$);return{kind:"replace-block",block:e($.list,$.list.items.flatMap((J,X)=>{if(X===$.itemIndex-1)return[Z.item];if(X===$.itemIndex)return[];return[J]})),blockId:$.list.id,selection:q0($.rootIndex,Z.regionChildIndices)}}function d$($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((X,Y)=>Y!==$.itemIndex),Z=$.parentItem.children.flatMap((X)=>{if(X.type!=="list"||X.id!==$.list.id)return[X];if(M.length===0)return[];return[e($.list,M)]}),J=j0($.parentItem,Z);return{kind:"replace-block",block:e($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),J,$.item,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,selection:q1($.rootIndex,$.parentListChildIndices,$.parentItemIndex+1)}}function Z3($,M){let Z=$.itemIndex+M;if(Z<0||Z>=$.list.items.length)return null;let J=[...$.list.items],[X]=J.splice($.itemIndex,1);if(!X)return null;return J.splice(Z,0,X),{kind:"replace-block",block:e($.list,J),blockId:$.list.id,selection:q1($.rootIndex,$.listChildIndices,Z)}}function AD($){if(!$.parentItem||$.parentItemIndex===null||!$.parentItemChildIndices||!$.parentList||!$.parentListChildIndices)return null;let M=$.list.items.filter((Q,K)=>K!==$.itemIndex),Z=$.parentItem.children.flatMap((Q)=>{if(Q.type!=="list"||Q.id!==$.list.id)return[Q];if(M.length===0)return[];return[e($.list,M)]}),J=j0($.parentItem,Z),X=typeof $.parentItem.checked==="boolean"?!1:$.parentItem.checked,Y=V4("",X,$.parentItem.spread);return{kind:"replace-block",block:e($.parentList,[...$.parentList.items.slice(0,$.parentItemIndex),J,Y,...$.parentList.items.slice($.parentItemIndex+1)]),blockId:$.parentList.id,listItemInsertedPath:g5(Y,$.rootIndex,[...$.parentListChildIndices,$.parentItemIndex+1]),selection:q1($.rootIndex,$.parentListChildIndices,$.parentItemIndex+1)}}function g5($,M,Z){return typeof $.checked==="boolean"?void 0:S$(M,Z)}function ND($,M,Z){let J=$.children.findIndex((Y)=>Y.type==="list"&&Y.ordered===Z.list.ordered&&Y.start===Z.list.start);if(J>=0){let Y=$.children[J];if(!Y||Y.type!=="list")return{item:$,regionChildIndices:[...Z.listChildIndices,Z.itemIndex-1,0]};return{item:j0($,$.children.map((Q,K)=>K===J?e(Y,[...Y.items,M]):Q)),regionChildIndices:[...Z.listChildIndices,Z.itemIndex-1,J,Y.items.length,0]}}let X=W1({items:[M],ordered:Z.list.ordered,spread:Z.list.spread,start:Z.list.start});return{item:j0($,[...$.children,X]),regionChildIndices:[...Z.listChildIndices,Z.itemIndex-1,$.children.length,0,0]}}function r$($,M){let Z=$.region.text.length,J=$.region.text.slice(0,M),X=$.region.text.slice(M),Y=M===0&&Z>0?$.rootIndex:$.rootIndex+1;if($.block.type==="paragraph")return{kind:"splice-blocks",blocks:M===0?[x({text:""}),$.block]:M===Z?[$.block,x({text:""})]:[x({text:J}),x({text:X})],rootIndex:$.rootIndex,selection:$0(Y)};return{kind:"splice-blocks",blocks:M===0?[x({text:""}),$.block]:M===Z?[$.block,x({text:""})]:[Z1({depth:$.block.depth,text:J}),x({text:X})],rootIndex:$.rootIndex,selection:$0(Y)}}function c$($,M){let Z=$.region.text,J=Z.slice(0,M),X=Z.slice(M),Y=$.block.type==="heading"?yD($.block,J,X,$.blockChildIndices,M,Z.length):WD($.block,J,X,$.blockChildIndices,M,Z.length);return{kind:"splice-blocks",blocks:[W0({children:[...$.quote.children.slice(0,$.childIndex),...Y.blocks,...$.quote.children.slice($.childIndex+1)]})],rootIndex:$.rootIndex,selection:q0($.rootIndex,Y.focusChildIndices)}}function a$($,M){if(M!==0||$.region.text.length!==0||$.block.type!=="paragraph")return null;let Z=$.quote.children.slice(0,$.childIndex),J=$.quote.children.slice($.childIndex+1),X=[];if(Z.length>0)X.push(W0({children:Z}));if(X.push(x({text:""})),J.length>0)X.push(W0({children:J}));return{kind:"splice-blocks",blocks:X,rootIndex:$.rootIndex,selection:$0($.rootIndex+(Z.length>0?1:0))}}function i$($,M){let Z=zD($);if(Z)return Z;if($.rootIndex===0)return null;let J=M.document.blocks[$.rootIndex-1],X=M.document.blocks[$.rootIndex+1];if(!J)return null;if($.block.plainText.length===0){let Y=_D($,J,X);if(Y)return Y;return{kind:"splice-blocks",blocks:[],rootIndex:$.rootIndex,selection:J.type==="paragraph"||J.type==="heading"?$0($.rootIndex-1,"end"):J.type==="list"?q0($.rootIndex-1,[J.items.length-1,0],"end"):J.type==="blockquote"?q0($.rootIndex-1,[J.children.length-1],"end"):$0($.rootIndex-1,"end")}}if(J.type==="paragraph")return{kind:"splice-blocks",count:2,blocks:[x({text:`${J.plainText}${$.block.plainText}`})],rootIndex:$.rootIndex-1,selection:$0($.rootIndex-1,J.plainText.length)};if(J.type==="heading")return{kind:"splice-blocks",count:2,blocks:[Z1({depth:J.depth,text:`${J.plainText}${$.block.plainText}`})],rootIndex:$.rootIndex-1,selection:$0($.rootIndex-1,J.plainText.length)};if(J.type==="list"){let Y=J.items.length-1,Q=J.items[Y];if(Q){let K=_2(Q,`${Q.plainText}${$.block.plainText}`);if(K)return{kind:"splice-blocks",count:2,blocks:[e(J,J.items.map((q,D)=>D===Y?K:q))],rootIndex:$.rootIndex-1,selection:q0($.rootIndex-1,[Y,0],Q.plainText.length)}}}return null}function s$($){if($.region.text.length===0)return ED($);if($.childIndex>0)return HD($);return{kind:"splice-blocks",blocks:$.quote.children,rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function J3($,M,Z){if($.block.type!=="heading")return null;let J=Math.max(1,Math.min(6,$.block.depth+M));if(J===$.block.depth)return{kind:"keep-state"};return{kind:"splice-blocks",blocks:[Z1({depth:J,text:$.block.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex,Z)}}function _D($,M,Z){if($.block.type!=="paragraph"||$.block.plainText.length!==0||M.type!=="list"||Z?.type!=="list"||!FD(M,Z))return null;let J=M.items.length-1;return{kind:"splice-blocks",count:3,blocks:[e(M,[...M.items,...Z.items])],rootIndex:$.rootIndex-1,selection:q0($.rootIndex-1,[J,0],"end")}}function FD($,M){return $.ordered===M.ordered&&$.start===M.start}function zD($){if($.block.type!=="heading")return null;return{kind:"splice-blocks",blocks:[x({text:$.block.plainText})],rootIndex:$.rootIndex,selection:$0($.rootIndex)}}function HD($){let Z=$.quote.children[$.childIndex-1].plainText,J=$.block.plainText,X=$.quote.children.filter((Y,Q)=>Q!==$.childIndex).map((Y,Q)=>Q===$.childIndex-1?x({text:`${Z}${J}`}):Y);return{kind:"splice-blocks",blocks:[W0({children:X})],rootIndex:$.rootIndex,selection:q0($.rootIndex,[$.childIndex-1],Z.length)}}function ED($){if($.quote.children.length===1)return{kind:"splice-blocks",blocks:[x({text:""})],rootIndex:$.rootIndex,selection:$0($.rootIndex)};let M=Math.max(0,$.childIndex-1),Z=$.childIndex>0?"end":0;return{kind:"splice-blocks",blocks:[W0({children:$.quote.children.filter((J,X)=>X!==$.childIndex)})],rootIndex:$.rootIndex,selection:q0($.rootIndex,[M],Z)}}function WD($,M,Z,J,X,Y){return{blocks:X===0?[x({text:""}),$]:X===Y?[$,x({text:""})]:[x({text:M}),x({text:Z})],focusChildIndices:X===0?J:[...J.slice(0,-1),J.at(-1)+1]}}function yD($,M,Z,J,X,Y){return{blocks:X===0?[x({text:""}),$]:X===Y?[$,x({text:""})]:[Z1({depth:$.depth,text:M}),x({text:Z})],focusChildIndices:X===0?J:[...J.slice(0,-1),J.at(-1)+1]}}function o$($,M,Z){let J=A2($,M),X=Math.max(2,Z);if(!J||J.block.type!=="paragraph"||J.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:[y1({rows:Array.from({length:2},()=>Y3(X))})],rootIndex:J.rootIndex,selection:L1(J.rootIndex,0,0)}}function X3($,M,Z,J){let X=J<0?bD(Z.table,Z.rowIndex,Z.cellIndex):TD(Z.table,Z.rowIndex,Z.cellIndex);if(!X)return J>0&&jD(Z.table,Z.rowIndex,Z.cellIndex)?BD(Z):{kind:"keep-state"};let Y=Z.table.rows[X.rowIndex]?.cells[X.cellIndex];if(!Y)return{kind:"keep-state"};return{kind:"set-selection",selection:wD($,M,Z.table,X.rowIndex,X.cellIndex,Math.min(M.focus.offset,Y.plainText.length))}}function n$($,M){let Z=D2($,M.focus.regionId);if(!Z||Z.kind!=="tableCell")return null;let J=Math.min(M.anchor.offset,M.focus.offset),X=Math.max(M.anchor.offset,M.focus.offset),Y=s2(Z,J,X,(Q)=>M5({path:Q}));return{kind:"replace-block",block:Y.block,blockId:Y.blockId,selection:Y.selection}}function t$($,M){let Z=M==="left"?$.cellIndex:$.cellIndex+1;return F2($,y1({align:XM($.table.align,Z,0,[null]),rows:$.table.rows.map((J)=>c1({cells:PD(J.cells,Z,0,[JM()])}))}),L1($.rootIndex,$.rowIndex,Z))}function e$($){let M=Math.max(0,...$.table.rows.map((Z)=>Z.cells.length));if(M<=1)return null;return F2($,y1({align:XM($.table.align,$.cellIndex,1,[]),rows:$.table.rows.map((Z)=>c1({cells:Z.cells.filter((J,X)=>X!==$.cellIndex)}))}),L1($.rootIndex,$.rowIndex,Math.min($.cellIndex,M-2)))}function $M($,M){let Z=M==="above"?$.rowIndex:$.rowIndex+1,J=Math.max(1,...$.table.rows.map((X)=>X.cells.length));return F2($,w0($.table,[...$.table.rows.slice(0,Z),Y3(J),...$.table.rows.slice(Z)]),L1($.rootIndex,Z,Math.min($.cellIndex,J-1)))}function MM($){if($.table.rows.length<=1)return null;let M=$.table.rows.filter((X,Y)=>Y!==$.rowIndex),Z=Math.min($.rowIndex,M.length-1),J=M[Z]?.cells.length??1;return F2($,w0($.table,M),L1($.rootIndex,Z,Math.min($.cellIndex,J-1)))}function ZM($){return F2($,x({text:""}),$0($.rootIndex))}function Y3($){return c1({cells:Array.from({length:$},()=>JM())})}function JM(){return J1({children:[]})}function BD($){let M=$.table.rows.length,Z=Math.max(1,...$.table.rows.map((J)=>J.cells.length));return F2($,w0($.table,[...$.table.rows,Y3(Z)]),L1($.rootIndex,M,0))}function F2($,M,Z){return{kind:"replace-block",block:M,blockId:$.table.id,selection:Z}}function PD($,M,Z,J){return[...$.slice(0,M),...J,...$.slice(M+Z)]}function XM($,M,Z,J){return[...$.slice(0,M),...J,...$.slice(M+Z)]}function wD($,M,Z,J,X,Y){let Q=V2($,Z.id,J,X);if(!Q)return M;return{anchor:{regionId:Q.id,offset:Y},focus:{regionId:Q.id,offset:Y}}}function bD($,M,Z){if(Z>0)return{cellIndex:Z-1,rowIndex:M};if(M>0){let J=$.rows[M-1];if(!J||J.cells.length===0)return null;return{cellIndex:J.cells.length-1,rowIndex:M-1}}return null}function TD($,M,Z){let J=$.rows[M];if(!J)return null;if(Z+1<J.cells.length)return{cellIndex:Z+1,rowIndex:M};let X=$.rows[M+1];if(!X||X.cells.length===0)return null;return{cellIndex:0,rowIndex:M+1}}function jD($,M,Z){let J=$.rows[M];return Boolean(J&&M===$.rows.length-1&&Z===J.cells.length-1)}function U4($,M){let Z=m$($.documentIndex,$.selection,M),J=d($,Z);if(!J)return null;if(Z?.kind==="splice-text"&&M.length>0)J=k5(J,M.length);if(M===".")J=U$(J);return J}function p5($){let M=D4($.documentIndex,$.selection),Z=J0($.documentIndex,$.selection).start.offset;switch(M.kind){case"code":return d($,{kind:"splice-text",selection:$.selection,text:`
|
|
25
|
-
`});case"tableCell":return d($,n$($.documentIndex,$.selection));case"listItem":{let J=p$(M,Z);return RD({state:d($,J)??d($,M3(M,Z)),action:J})}case"blockquoteTextBlock":return d($,a$(M,Z))??d($,c$(M,Z));case"rootTextBlock":return d($,r$(M,Z));case"unsupported":return null}}function l5($,M){let Z=d($,{kind:"splice-text",selection:$.selection,text:M});return M.length>0?k5(Z,M.length):Z}function x5($){return l5($,"")}function Q3($){return e6($.documentIndex,$.selection)}function YM($,M,Z){let J=$3($,M);if(J)return OD(J,M);if(M.kind==="text")return null;return CD($,M,Z)}function OD($,M){let Z=LD(M);return Z>0?k5($,Z):$}function LD($){switch($.kind){case"text":return $.text.length;case"inlines":return X0($.inlines).length;case"blocks":return $.blocks.length===1&&$.blocks[0].type==="paragraph"?$.blocks[0].plainText.length:0}}function CD($,M,Z){let J=I5($.documentIndex,$.selection);if(!J)return null;let X=J.prefersVerbatimFallback&&Z&&Z.length>0?Z:L9(M);return X.length>0?l5($,X):null}function K3($){if(SM($))return x5($);let M=kM($,"backward");if(M)return M;let Z=J0($.documentIndex,$.selection);if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==0||Z.end.offset!==0)return null;let J=D4($.documentIndex,$.selection);switch(J.kind){case"listItem":return d($,l$(J));case"blockquoteTextBlock":return d($,s$(J));case"rootTextBlock":return d($,i$(J,$.documentIndex));default:return null}}function D3($){if(SM($))return x5($);return kM($,"forward")}function QM($,M,Z){return E0($,M,Z,!0)}function KM($){let M=$.documentIndex.regions,Z=M[0],J=M.at(-1);if(!Z||!J)return $;return Q0($,{anchor:{regionId:Z.id,offset:0},focus:{regionId:J.id,offset:J.text.length}})}function DM($){let M=D4($.documentIndex,$.selection);switch(M.kind){case"tableCell":return d($,X3($.documentIndex,$.selection,M,1));case"rootTextBlock":return d($,J3(M,1,$.selection.focus.offset));case"listItem":return d($,x$(M));default:return null}}function qM($){let M=D4($.documentIndex,$.selection);switch(M.kind){case"tableCell":return d($,X3($.documentIndex,$.selection,M,-1));case"rootTextBlock":return d($,J3(M,-1,$.selection.focus.offset));case"listItem":return d($,d$(M));default:return null}}var VM=S1(N2,($,M)=>Z3(M,-1)),UM=S1(N2,($,M)=>Z3(M,1));function GM($,M){let Z=K4($.documentIndex,M);if(!Z||Z.type!=="listItem"||typeof Z.checked!=="boolean")return null;return d($,{kind:"replace-block",block:{...Z,checked:!Z.checked},blockId:M})}function AM($,M){return d($,o$($.documentIndex,$.selection,M))}var NM=S1(G4,($,M,Z)=>t$(M,Z)),_M=S1(G4,($,M)=>e$(M)),FM=S1(G4,($,M,Z)=>$M(M,Z)),zM=S1(G4,($,M)=>MM(M)),HM=S1(G4,($,M)=>ZM(M));function d5($){return i5($,"bold")}function r5($){return i5($,"italic")}function c5($){return i5($,"strikethrough")}function a5($){return i5($,"underline")}function EM($){return CM($,k6)}function WM($,M,Z,J,X){return RM($,M,Z,J,X)}function yM($,M,Z,J){return RM($,M,Z,J,null)}function BM($,M,Z){return d($,c7($.documentIndex,$.selection,(J)=>E1({alt:Z??null,path:J,url:M})))}function PM($,M,Z,J){let X=D2($.documentIndex,M);if(!X)return null;let{image:Y}=Z,Q=s2(X,Z.start,Z.end,(K)=>E1({alt:Y.alt,path:K,title:Y.title,url:Y.url,width:J}));return d($,{kind:"replace-block",block:Q.block,blockId:Q.blockId})}function wM($,M,Z){let J=P6($.documentIndex,M,Z);if(!J)return null;return mM($,$.documentIndex.document.comments.length,0,[J])}function bM($,M,Z){return A4($,M,(J)=>p8(J,{body:Z.trim()}))}function TM($,M,Z,J){return A4($,M,(X)=>l8(X,Z,J))}function jM($,M,Z){return A4($,M,(J)=>x8(J,Z))}function OM($,M){return A4($,M,()=>null)}function LM($,M,Z){return A4($,M,(J)=>d8(J,Z))}function q3($){return a6($)}function V3($){return i6($)}function S1($,M){return(Z,...J)=>{let X=$(Z.documentIndex,Z.selection);return X?d(Z,M(Z,X,...J)):null}}function G4($,M){return o6($,M.focus.regionId)}function RD($){if(!$.state||!$.action||$.action.kind!=="replace-block"||!$.action.listItemInsertedPath)return $.state;return G$($.state,$.action.listItemInsertedPath)}function i5($,M){return CM($,(Z,J,X)=>R6(Z,J,X,M))}function CM($,M){let Z=J0($.documentIndex,$.selection);if(Z.start.regionId!==Z.end.regionId||Z.start.offset===Z.end.offset)return null;return d($,j5($.documentIndex,Z.start.regionId,Z.start.offset,Z.end.offset,M))}function RM($,M,Z,J,X){return d($,m6($.documentIndex,M,Z,J,X))}function SM($){let M=J0($.documentIndex,$.selection);return M.start.regionId!==M.end.regionId||M.start.offset!==M.end.offset}function kM($,M){let Z=k$($,M);if(!Z)return null;let J=d($,Z.action);if(!J)return null;return V$($,J,Z.startOffset,Z.endOffset)}function A4($,M,Z){let X=C0($.documentIndex).threads[M];if(!X)return null;let Y=Z(X);if(Y===X)return null;return mM($,M,1,Y?[Y]:[])}function mM($,M,Z,J){return d($,{kind:"splice-comments",count:Z,index:M,threads:J})}var fM=1;function vM($,M,Z){let J=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(J===void 0)return $;let X=$.documentIndex.regions[J],Y=$.selection.focus.offset+M;if(Y>=0&&Y<=X.text.length)return E0($,X.id,Y,Z);if(M<0){let K=$.documentIndex.regions[J-1];if(!K)return $;return E0($,K.id,K.text.length,Z)}let Q=$.documentIndex.regions[J+1];if(!Q)return $;return E0($,Q.id,0,Z)}function uM($,M,Z,J,X){let Y=h2(M,Z.regionId,Z.offset);if(!Y)return $;let Q=M.lines[Y.index+J];if(!Q)return $;let K=b0(M,$,{x:p0($,M,Z)+fM,y:Q.top+Q.height/2});if(!K)return $;return E0($,K.regionId,K.offset,X)}function hM($,M,Z,J){let X=gM($,M);if(!X)return $;return E0($,X.regionId,Z==="Home"?X.start:X.end,J)}function IM($,M,Z,J,X){let Y=gM($,M);if(!Y)return $;let K=Math.max(1,Math.floor(480/M.options.lineHeight)),q=h2(M,Y.regionId,$.selection.focus.offset),D=q?M.lines[q.index+J*K]:null;if(!D)return $;let V=b0(M,$,{x:p0($,M,Z)+fM,y:D.top+D.height/2});if(!V)return $;return E0($,V.regionId,V.offset,X)}function gM($,M){return L0(M,$.selection.focus.regionId,$.selection.focus.offset)}var SD=1;function pM($,M,Z,J,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=kD($,K.id,Q.rowIndex+J,Q.cellIndex)??mD($,K.id,J);if(!q)return $;let D=M.regionBounds.get(Y.id),V=M.regionBounds.get(q.id);if(!D||!V)return $;let G=V.top+fD(Z.top+Z.height/2-D.top,0,Math.max(0,V.bottom-V.top-1)),U=b0(M,$,{x:p0($,M,Z)+SD,y:G});if(!U)return $;return E0($,U.regionId,U.offset,X)}function kD($,M,Z,J){return V2($.documentIndex,M,Z,J)}function mD($,M,Z){let J=$.documentIndex.blockIndex.get(M),X=$.documentIndex.regions,Y=J?$.documentIndex.roots[J.rootIndex]?.regionRange:void 0;if(!Y)return null;return Z<0?X[Y.start-1]??null:X[Y.end]??null}function fD($,M,Z){return Math.max(M,Math.min(Z,$))}function U3($,M,Z=!1){return vM($,M,Z)}function G3($,M,Z,J=!1){return vD($,M,Z,J)}function A3($,M,Z,J=!1){return uD($,M,Z,J)}function N3($,M,Z,J=!1){return hM($,M,Z,J)}function _3($,M,Z=!1){return hD($,M,Z)}function vD($,M,Z,J){let X=lM($,M);if(!X)return $;return pM($,M,X,Z,J)??uM($,M,X,Z,J)}function uD($,M,Z,J){let X=lM($,M);if(!X)return $;return IM($,M,X,Z,J)}function hD($,M,Z){let J=$.documentIndex.regions,X=M==="start"?J[0]:J.at(-1);if(!X)return $;return E0($,X.id,M==="start"?0:X.text.length,Z)}function lM($,M){return g0(M,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}function dM($,M,Z,J,X,Y,Q){let K=Z.image?J.images.get(Z.image.url):null,q=pD(Z,J,Q),D=lD(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 ID($,X,{...D,status:K?.status==="error"?"error":"loading"});$.strokeStyle=X.imageSurfaceBorder,$.strokeRect(D.left,D.top,D.width,D.height)}function ID($,M,Z){let J=Z.status==="loading"?"Loading image":"Image unavailable",X=xD(Z),Y=Z.top+Z.height/2+X.size*0.9;if($.save(),$.beginPath(),$.rect(Z.left,Z.top,Z.width,Z.height),$.clip(),Z.status==="loading")gD($,M,Z);$.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(J,Z.left+Z.width/2,Y),$.restore()}function gD($,M,Z){let J=Math.max(48,Math.round(Z.width*0.22)),X=Z.width+J*2,Y=performance.now()%1800/1800,Q=Z.left-J+X*Y,K=$.createLinearGradient(Q,Z.top,Q+J,Z.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(Z.left,Z.top,Z.width,Z.height)}function pD($,M,Z){if(!$.image)return xM(Z);let J=M.images.get($.image.url);if(!J||J.intrinsicWidth<=0||J.intrinsicHeight<=0)return xM(Z);return Math.max(48,Math.round(Z*(J.intrinsicHeight/J.intrinsicWidth)))}function lD($,M,Z,J){return{height:J,left:M,top:$.top+Math.max(0,Math.floor(($.height-J)/2)),width:Z}}function xD($){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 xM($){return Math.max(48,Math.round($*0.5625))}var rM=2,cM=8,dD=3,rD=1.5,cD=2,z2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function aM($,M,Z,J,X,Y,Q=null){if(!Z||M.start!==0)return;if(Q){let K=D$(Q),q=nD(Z,M,J,X,$);$.save(),$.translate(q.x,q.y),$.scale(K,K),$.translate(-q.x,-q.y)}if(Z.kind==="task")aD($,M,Z.checked,Y,Q);else if($.fillStyle=Q?e2(Y.listMarkerText,Q,Y):Y.listMarkerText,Z.kind==="ordered")oD($,Z.label,J,X);else $.fillText(Z.label,M.left-rM,X);if(Q)$.restore()}function aD($,M,Z,J,X=null){let Y=g2(M);if(iD($,Y,Z,J,X),!Z)return;sD($,Y,J,X)}function iD($,M,Z,J,X=null){let Y=Z?J.checkboxCheckedFill:J.checkboxUncheckedFill,Q=Z?J.checkboxCheckedStroke:J.checkboxUncheckedStroke;$.fillStyle=X?e2(Y,X,J):Y,$.strokeStyle=X?e2(Q,X,J):Q,$.beginPath(),$.lineWidth=rD,$.roundRect(M.left,M.top,M.size,M.size,dD),$.fill(),$.stroke()}function sD($,M,Z,J=null){$.strokeStyle=J?e2(Z.checkboxCheckmark,J,Z):Z.checkboxCheckmark,$.lineWidth=cD,$.beginPath(),$.moveTo(M.left+z2.start.x,M.top+z2.start.y),$.lineTo(M.left+z2.elbow.x,M.top+z2.elbow.y),$.lineTo(M.left+z2.end.x,M.top+z2.end.y),$.stroke()}function oD($,M,Z,J){let X=$.textAlign;$.textAlign="right",$.fillText(M,Z-cM,J),$.textAlign=X}function nD($,M,Z,J,X){if($.kind==="task"){let K=g2(M);return{x:K.left+K.size/2,y:K.top+K.size/2}}let Y=X.measureText($.label),Q=J-(Y.actualBoundingBoxAscent-Y.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:Z-cM-Y.width/2,y:Q};return{x:M.left-rM+Y.width/2,y:Q}}var tD=80;function sM({context:$,containerBounds:M,isHeaderRow:Z,lineHeight:J,theme:X}){let Y=nM(M,J);$.fillStyle=Z?X.tableHeaderBackground:X.tableBodyBackground,$.fillRect(Y.left,Y.top,Y.width,Y.height),tM($,Y,X)}function oM({activeBlockFlashes:$,activeBlockId:M,activeRegionId:Z,context:J,editorState:X,endIndex:Y,layout:Q,regionBounds:K,startIndex:q,theme:D,verticalBleed:V}){if(!M||!Z)return;let G=X.documentIndex.blockIndex.get(M)??null;if(G?.type!=="table")return;if((X.documentIndex.regionIndex.get(Z)??null)?.blockId!==M)return;let A=K.get(Z)??null,_=Q.regionLineIndices.get(Z)??null;if(!A||!_||_.length===0)return;let N=Q.lines[_[0]]??null;if(!N)return;let z=nM(A,N.height);if(z.width===0)return;let E=iM({context:J,endIndex:Y,fillStyle:D.activeBlockBackground,layout:Q,left:z.left,lineIndices:_,startIndex:q,verticalBleed:V,width:z.width}),L=G.path?$.get(G.path)??null:null;if(L)iM({context:J,endIndex:Y,fillStyle:S5(D.activeBlockFlash,L),layout:Q,left:z.left,lineIndices:_,startIndex:q,verticalBleed:V,width:z.width});if(!E)return;tM(J,z,D)}function iM({context:$,endIndex:M,fillStyle:Z,layout:J,left:X,lineIndices:Y,startIndex:Q,verticalBleed:K,width:q}){$.fillStyle=Z;let D=!1;for(let V of Y){if(V<Q)continue;if(V>=M)break;let G=J.lines[V];$.fillRect(X,G.top-K,q,G.height),D=!0}return D}function nM($,M){return{height:Math.max($.bottom-$.top,M),left:$.left,top:$.top,width:Math.max($.right-$.left,tD)}}function tM($,M,Z){$.strokeStyle=Z.tableBorder,$.strokeRect(M.left,M.top,M.width,M.height)}var F3=2,eD=3,$q=12,Mq=6,Zq=3,Jq=1,Xq=2,Yq=2,Qq=8,Kq=12,Dq=28,qq=4,Vq=5,Uq=2,Gq=3,Aq=6,eM=3,Nq=12,_q=10,Fq=2,zq=2,Hq=1,Eq=2,z3=2,$Z=1.25,Wq=5,yq=1,MZ=4,Bq=4,Pq=1.5;function wq({activeBlockId:$,activeRegionId:M,activeThreadIndex:Z,containerLineBounds:J,context:X,devicePixelRatio:Y,editorState:Q,height:K,layout:q,liveCommentRanges:D,normalizedSelection:V,now:G=sq(),resources:U,runtimeBlockMap:A,theme:_,viewportTop:N,width:z}){X.save(),X.scale(Y,Y),X.clearRect(0,0,z,K),X.fillStyle=_.background,X.fillRect(0,0,z,K),X.textBaseline="alphabetic",X.translate(0,-N);let E=bq(Q,V),{endIndex:L,startIndex:W}=D6(q,N,K),R=e7(Q,G),S=$$(Q,G),I=t7(Q,G),y=Z$(Q,G),b=M$(Q,G),H=jq(q,Q,$,W,L),j=Tq(q,Q,A,W,L,z);for(let B=W;B<L;B+=1){let P=q.lines[B];Rq({containerLineBounds:J,context:X,editorState:Q,line:P,runtimeBlockMap:A,theme:_,width:z})}oM({activeBlockFlashes:R,activeBlockId:$,activeRegionId:M,context:X,editorState:Q,endIndex:L,layout:q,regionBounds:J,startIndex:W,theme:_,verticalBleed:F3});for(let B=W;B<L;B+=1){let P=q.lines[B];Sq({activeBlockId:$,activeBlockFlashes:R,activeDeletedTextFades:S,activeThreadIndex:Z,activeInsertedTextHighlights:I,activeListMarkerPops:y,activePunctuationPulses:b,context:X,editorState:Q,line:P,liveCommentRanges:D,normalizedSelection:V,resources:U,runtimeBlockMap:A,selectionRegionOrderRange:E,theme:_,width:z})}Oq(X,j,_),Lq(X,H,_),X.restore()}function bq($,M){let Z=$.documentIndex.regionOrderIndex,J=Z.get(M.start.regionId),X=Z.get(M.end.regionId);return J===void 0||X===void 0?null:{end:X,start:J}}function Tq($,M,Z,J,X,Y){let Q=new Map;for(let K=J;K<X;K+=1){let q=$.lines[K],D=Z.get(q.blockId);if(D?.type!=="heading"||D.depth!==1&&D.depth!==2)continue;let V=Q.get(D.id),G={bottom:q.top+q.height,left:q.left+I0(M,q),right:Y-$.options.paddingX};Q.set(D.id,V?{bottom:Math.max(V.bottom,G.bottom),left:V.left,right:V.right}:G)}return Q}function jq($,M,Z,J,X){let Y=new Map;for(let Q=J;Q<X;Q+=1){let K=$.lines[Q],q=X2(M,K.blockId,"blockquote");if(!q)continue;let D=Y.get(q.id),V={bottom:K.top+K.height,isActive:K.blockId===Z,left:$.options.paddingX+(q.depth+1)*$.options.indentWidth-10,top:K.top};Y.set(q.id,D?{bottom:Math.max(D.bottom,V.bottom),isActive:D.isActive||V.isActive,left:D.left,top:Math.min(D.top,V.top)}:V)}return Y}function Oq($,M,Z){$.fillStyle=Z.headingRule;for(let J of M.values())$.fillRect(J.left,J.bottom+Wq,Math.max(z3,J.right-J.left),yq)}function Lq($,M,Z){for(let J of M.values())$.fillStyle=J.isActive?Z.blockquoteRuleActive:Z.blockquoteRule,$.fillRect(J.left,J.top+eD,Zq,Math.max($q,J.bottom-J.top-Mq))}function Cq({context:$,devicePixelRatio:M,editorState:Z,height:J,layout:X,normalizedSelection:Y,presence:Q,showCaret:K,theme:q,viewportTop:D,width:V}){$.save(),$.scale(M,M),$.clearRect(0,0,V,J);let G=Y.start.regionId===Y.end.regionId&&Y.start.offset!==Y.end.offset,U=K&&!G;if($.translate(0,-D),U)ZZ($,Z,X,{color:q.caret,offset:Z.selection.focus.offset,regionId:Z.selection.focus.regionId});if(Q)for(let A of Q){if(!A.cursorPoint)continue;ZZ($,Z,X,{color:A.color??q.leafAccent,offset:A.cursorPoint.offset,regionId:A.cursorPoint.regionId})}$.restore()}function ZZ($,M,Z,J){let X=g0(Z,M.documentIndex,{regionId:J.regionId,offset:J.offset});if(!X)return;let Y=p0(M,Z,X),Q=gq(Z,X);$.fillStyle=J.color,$.fillRect(Y,Q.top,Xq,Q.height)}function Rq({containerLineBounds:$,context:M,editorState:Z,line:J,runtimeBlockMap:X,theme:Y,width:Q}){let K=X.get(J.blockId)??null,q=$.get(J.regionId)??null,D=Z.documentIndex.tableCellIndex.get(J.regionId)??null;kq(M,J,K,q,D,Y,Q)}function Sq({activeBlockId:$,activeBlockFlashes:M,activeDeletedTextFades:Z,activeThreadIndex:J,activeInsertedTextHighlights:X,activeListMarkerPops:Y,activePunctuationPulses:Q,context:K,editorState:q,line:D,liveCommentRanges:V,normalizedSelection:G,resources:U,runtimeBlockMap:A,selectionRegionOrderRange:_,theme:N,width:z}){let E=A.get(D.blockId)??null,L=q.documentIndex.blockIndex.get(D.blockId)?.path??null,W=q.documentIndex.regionIndex.get(D.regionId)??null,R=W?.path??"",S=X2(q,D.blockId,"listItem"),I=S?p2(q,S.id):null,y=S?Y.get(S.path)??null:null,b=D.left+I0(q,D),H=xq(D),j=E?.type==="code"?N.codeText:cq(E,N);K.font=D.font,mq(K,D,E,L,$,M,N,z),fq(K,q,D,G,_,N),vq(K,q,D,V,J,N),aM(K,D,I,b,H,N,y),uq(K,D,W,b,H,X.get(R)??[],j,U,N),hq(K,D,W,b,H,Z.get(R)??[],j),Iq(K,D,W,b,H,Q.get(R)??[],N)}function kq($,M,Z,J,X,Y,Q){if(!J||M.start!==0)return;if(Z?.type==="code"){let K=Math.max(0,M.left-Kq);$.fillStyle=Y.codeBackground,$.fillRect(K,J.top-qq,Math.max(J.right-M.left+Dq,Q-K),J.bottom-J.top+Qq);return}if(Z?.type!=="table")return;sM({context:$,containerBounds:J,isHeaderRow:X?.rowIndex===0,lineHeight:M.height,theme:Y})}function mq($,M,Z,J,X,Y,Q,K){if(M.blockId!==X||Z?.type==="table")return;let q=J?Y.get(J)??null:null;if($.fillStyle=Q.activeBlockBackground,$.fillRect(0,M.top-F3,K,M.height),!q)return;$.fillStyle=S5(Q.activeBlockFlash,q),$.fillRect(0,M.top-F3,K,M.height)}function fq($,M,Z,J,X,Y){if(!X)return;let Q=M.documentIndex.regionOrderIndex.get(Z.regionId);if(Q===void 0||Q<X.start||Q>X.end)return;let K=Q===X.start?Math.max(Z.start,J.start.offset):Z.start,q=Q===X.end?Math.min(Z.end,J.end.offset):Z.end;if(q<=K)return;$.fillStyle=Y.selectionBackground,$.fillRect(D1(M,Z,K-Z.start),Z.top+Hq,Math.max(zq,D1(M,Z,q-Z.start)-D1(M,Z,K-Z.start)),Z.height-Eq)}function vq($,M,Z,J,X,Y){for(let Q of J){if(Q.regionId!==Z.regionId)continue;let K=Math.max(Q.startOffset,Z.start),q=Math.min(Q.endOffset,Z.end);if(q<=K)continue;$.fillStyle=iq(Q,X,Y),$.fillRect(D1(M,Z,K-Z.start),Z.top+Z.height-Vq,Math.max(Uq,D1(M,Z,q-Z.start)-D1(M,Z,K-Z.start)),Gq)}}function uq($,M,Z,J,X,Y,Q,K,q){if(!Z){$.fillStyle=Q,$.fillText(M.text,J,X);return}let D=Z.inlines.filter((V)=>V.end>M.start&&V.start<M.end);if(D.length===0){$.fillStyle=Q,$.fillText(M.text,J,X);return}for(let V of D){let G=Math.max(M.start,V.start),U=Math.min(M.end,V.end);if(Z.text.slice(G,U).length===0)continue;let{left:_,right:N}=E3(M,J,G,U),z=aq(M.font,V.marks);if($.font=z,V.kind==="image"){let E=Math.max(24,N-_);dM($,M,V,K,q,_,E);continue}if(V.kind==="inlineCode"){let E=dq(M,z),L=rq(M,z);$.fillStyle=q.inlineCodeBackground,$.fillRect(_-eM,E,Math.max(_q,N-_+eM*2),L),JZ($,M,Z.text,J,X,G,U,q.inlineCodeText,Y,q,{strikethrough:!1,underline:!1});continue}JZ($,M,Z.text,J,X,G,U,V.link?q.linkText:Q,Y,q,{strikethrough:V.marks.includes("strikethrough"),underline:V.marks.includes("underline")||Boolean(V.link)})}}function JZ($,M,Z,J,X,Y,Q,K,q,D,V){let G=J$(Y,Q,q);for(let U=0;U<G.length-1;U+=1){let A=G[U],_=G[U+1];if(_<=A)continue;let N=Z.slice(A,_);if(N.length===0)continue;let{left:z,right:E}=E3(M,J,A,_),L=X$(q,A,_),W=Y$(K,L,D);if($.fillStyle=W,$.fillText(N,z,X),V.strikethrough)$.fillRect(z,lq(X,M.height,$.font),Math.max(z3,E-z),$Z);if(V.underline)$.fillRect(z,pq(X,M.height,$.font),Math.max(z3,E-z),$Z)}}function hq($,M,Z,J,X,Y,Q){if(!Z||Y.length===0)return;for(let K of Y){if(K.startOffset<M.start||K.startOffset>M.end)continue;let q=J+(y0(M,K.startOffset-M.start)-M.left);$.fillStyle=Q$(Q,K),$.fillText(K.text,q,X)}}function Iq($,M,Z,J,X,Y,Q){if(!Z||Y.length===0)return;for(let K of Y){if(K.offset<M.start||K.offset>=M.end)continue;let{left:q,right:D}=E3(M,J,K.offset,K.offset+1),V=Math.max(MZ,(D-q)/2+MZ+Bq*K.progress),{ascent:G,descent:U}=K1(M.font),A=X-Math.max(1,G*0.42)+Math.max(0.5,U*0.15);$.strokeStyle=K$(K,Q),$.lineWidth=Pq,$.beginPath(),$.arc((q+D)/2,A,V,0,Math.PI*2),$.stroke()}}function gq($,M){let Z=L0($,M.regionId,M.offset),J=Z?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:X,descent:Y}=K1(J),Q=Math.max(1,X+Y),K=Math.min(M.height-Yq,Q),q=Z?Math.max(Z.top,Z.top+H3(Z.height,J)-Jq):M.top+Math.max(0,Math.floor((M.height-K)/2));return{height:K,top:q}}function pq($,M,Z){let{descent:J}=K1(Z),X=Math.max(1,Math.round(Math.max(2,J)*0.35)),Y=$+J-X,Q=$-s5(M,Z);return Math.min(Q+M-4,Y)}function lq($,M,Z){let{ascent:J}=K1(Z),X=$-s5(M,Z);return Math.max(X+2,$-Math.round(J*0.32))}function xq($){return $.top+s5($.height,$.font)}function s5($,M){return L7($,M)}function dq($,M){let Z=H3($.height,M);return $.top+Z+Fq}function rq($,M){let Z=H3($.height,M);return Math.max(Nq,$.height-Z-Aq)}function H3($,M){let{ascent:Z}=K1(M);return s5($,M)-Z}function cq($,M){switch($?.type){case"heading":return M.headingText;case"blockquote":return M.blockquoteText;case"table":return M.headingText;default:return M.paragraphText}}function E3($,M,Z,J){return{left:M+(y0($,Z-$.start)-$.left),right:M+(y0($,J-$.start)-$.left)}}function aq($,M){let Z=[];if(M.includes("italic"))Z.push("italic");if(M.includes("bold"))Z.push("700");return Z.length>0?`${Z.join(" ")} ${$}`:$}function iq($,M,Z){if($.resolved)return $.threadIndex===M?Z.commentHighlightResolvedActive:Z.commentHighlightResolved;return $.threadIndex===M?Z.commentHighlightActive:Z.commentHighlight}function sq(){return typeof performance<"u"?performance.now():Date.now()}function W3($,M,Z,J){wq({activeBlockId:J.activeBlockId,activeRegionId:J.activeRegionId,activeThreadIndex:J.activeThreadIndex,containerLineBounds:M.regionBounds,context:Z,devicePixelRatio:J.devicePixelRatio,editorState:$,height:J.height,layout:M.layout,liveCommentRanges:J.liveCommentRanges,normalizedSelection:J.normalizedSelection,now:J.now,resources:J.resources??{images:new Map},runtimeBlockMap:M.blockMap,theme:J.theme,viewportTop:M.paintTop,width:J.width})}function y3($,M,Z,J){Cq({context:Z,devicePixelRatio:J.devicePixelRatio,editorState:$,height:J.height,layout:M.layout,normalizedSelection:J.normalizedSelection,presence:J.presence,showCaret:J.showCaret,theme:J.theme,viewportTop:M.paintTop,width:J.width})}import{forwardRef as $V,createElement as MV}from"react";var o5=(...$)=>$.filter((M,Z,J)=>{return Boolean(M)&&M.trim()!==""&&J.indexOf(M)===Z}).join(" ").trim();var XZ=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var YZ=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(M,Z,J)=>J?J.toUpperCase():Z.toLowerCase());var B3=($)=>{let M=YZ($);return M.charAt(0).toUpperCase()+M.slice(1)};import{forwardRef as eq,createElement as DZ}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 QZ=($)=>{for(let M in $)if(M.startsWith("aria-")||M==="role"||M==="title")return!0;return!1};import{createContext as oq,useContext as nq,useMemo as nH,createElement as tH}from"react";var tq=oq({});var KZ=()=>nq(tq);var qZ=eq(({color:$,size:M,strokeWidth:Z,absoluteStrokeWidth:J,className:X="",children:Y,iconNode:Q,...K},q)=>{let{size:D=24,strokeWidth:V=2,absoluteStrokeWidth:G=!1,color:U="currentColor",className:A=""}=KZ()??{},_=J??G?Number(Z??V)*24/Number(M??D):Z??V;return DZ("svg",{ref:q,...n5,width:M??D??n5.width,height:M??D??n5.height,stroke:$??U,strokeWidth:_,className:o5("lucide",A,X),...!Y&&!QZ(K)&&{"aria-hidden":"true"},...K},[...Q.map(([N,z])=>DZ(N,z)),...Array.isArray(Y)?Y:[Y]])});var v=($,M)=>{let Z=$V(({className:J,...X},Y)=>MV(qZ,{ref:Y,iconNode:M,className:o5(`lucide-${XZ(B3($))}`,`lucide-${$}`,J),...X}));return Z.displayName=B3($),Z};var ZV=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],V1=v("columns-2",ZV);var JV=[["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"}]],U1=v("rows-3",JV);var XV=[["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"}]],G1=v("send-horizontal",XV);var YV=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],N4=v("arrow-down",YV);var QV=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],_4=v("arrow-up",QV);var KV=[["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"}]],F4=v("bold",KV);var DV=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],k1=v("check",DV);var qV=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],z4=v("chevron-down",qV);var VV=[["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"}]],H4=v("heading-1",VV);var UV=[["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"}]],E4=v("heading-2",UV);var GV=[["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"}]],W4=v("heading-3",GV);var AV=[["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"}]],y4=v("heading-4",AV);var NV=[["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"}]],B4=v("heading-5",NV);var _V=[["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"}]],P4=v("heading-6",_V);var FV=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],w4=v("heading",FV);var zV=[["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"}]],b4=v("italic",zV);var HV=[["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"}]],T4=v("list-ordered",HV);var EV=[["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"}]],j4=v("list-todo",EV);var WV=[["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"}]],O4=v("list",WV);var yV=[["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"}]],L4=v("message-square-plus",yV);var BV=[["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"}]],m1=v("pencil",BV);var PV=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],H2=v("plus",PV);var wV=[["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"}]],C4=v("strikethrough",wV);var bV=[["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"}]],A1=v("table-2",bV);var TV=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],R4=v("text-quote",TV);var jV=[["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"}]],T0=v("trash-2",jV);var OV=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],S4=v("underline",OV);var LV=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],k4=v("x",LV);import{jsx as E2,jsxs as kV}from"react/jsx-runtime";function VZ({insetX:$,insetY:M,onSelect:Z,presence:J}){if(!J)return null;return E2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${M}px`},children:J.map((X)=>E2(CV,{onSelect:()=>Z(X),presence:X},X.id))})}function CV({onSelect:$,presence:M}){let Z=M.viewport,J=RV(M),X=Z?.status==="above"?_4:N4,Y=Z!==null&&Z.status!=="unresolved",Q=Z?.status==="above"||Z?.status==="below";return kV("button",{"aria-label":SV(M),className:"documint-presence-indicator","data-status":Z?.status??"unresolved",disabled:!Y,onClick:Y?$:void 0,style:{"--documint-presence-color":M.color??"var(--documint-leaf-accent)"},type:"button",children:[E2("span",{className:"documint-presence-indicator-avatar",children:M.avatarUrl?E2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:M.avatarUrl}):J}),Q?E2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:E2(X,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function RV($){return UZ($).charAt(0).toLocaleUpperCase()}function SV($){let M=UZ($),Z=$.viewport?.status??"unresolved";if(Z==="above")return`${M} above viewport`;if(Z==="below")return`${M} below viewport`;if(Z==="unresolved")return`${M} unresolved`;return`${M} in viewport`}function UZ($){return($.fullName??$.username).trim()||"Presence"}var o=`
|
|
26
|
-
`,N1="<ins>",m4="</ins>",W2=">",f4="```",t5=":::",P3=/^:::([A-Za-z][-\w]*)(.*)$/,e5="documint-comments";var $8="`",j3="\\",b3="![",T3="[",_Z="(",GZ=")",FZ=" ",zZ=":",mV=/[A-Za-z]/,fV=/[-A-Za-z0-9_]/,vV=/^\{width=([1-9]\d*)\}/,uV=/\\([\\`*_[\]{}()#+\-.!~|])/g,HZ=/\\(.)/g,hV=[{delimiter:"**",mark:"bold"},{delimiter:"~~",mark:"strikethrough"},{delimiter:"*",mark:"italic"}];function y2($,M=[]){return O3($,0,$.length,M)}function O3($,M,Z,J){let X=[],Y=M,Q=M;while(Y<Z){let K=IV($,Y,Z,J);if(K){AZ(X,$.slice(Q,Y),J),X.push(...K.nodes),Y=K.end,Q=Y;continue}if($[Y]===j3){Y+=Math.min(2,Z-Y);continue}Y+=1}return AZ(X,$.slice(Q,Z),J),gV(X)}function IV($,M,Z,J){switch($[M]){case zZ:return nV($,M,Z);case"<":return sV($,M,Z,J);case $8:return rV($,M,Z);case"!":return cV($,M,Z);case T3:return aV($,M,Z,J);case"*":case"~":return lV($,M,Z,J);default:return null}}function AZ($,M,Z){if(M.length===0)return;$.push(i0({marks:Z,text:PZ(M)}))}function L3($,M){return Z5({originalType:$,source:M})}function gV($){let M=[];for(let Z of $){let J=M.at(-1);if(J?.type==="text"&&Z.type==="text"&&xV(J.marks,Z.marks)){M[M.length-1]=i0({marks:J.marks,text:J.text+Z.text});continue}M.push(Z)}return M}function pV($,M,Z){for(let J of hV){if(!$.startsWith(J.delimiter,M))continue;let X=$.indexOf(J.delimiter,M+J.delimiter.length);if(X<0||X>=Z)continue;return{contentEnd:X,contentStart:M+J.delimiter.length,end:X+J.delimiter.length,mark:J.mark}}return null}function lV($,M,Z,J){let X=pV($,M,Z);if(!X)return null;return{end:X.end,nodes:O3($,X.contentStart,X.contentEnd,[...J,X.mark])}}function xV($,M){return $.length===M.length&&$.every((Z,J)=>Z===M[J])}function dV($,M,Z){if($[M]!==$8)return null;let J=1;while(M+J<Z&&$[M+J]===$8)J+=1;let X=$8.repeat(J),Y=$.indexOf(X,M+J);if(Y<0||Y>=Z)return null;return{end:Y+J,value:$.slice(M+J,Y)}}function rV($,M,Z){let J=dV($,M,Z);if(!J)return null;return{end:J.end,nodes:[d1({code:J.value})]}}function cV($,M,Z){if(!$.startsWith(b3,M))return null;let J=WZ($,M+1,Z);if(J<0||$[J+1]!==_Z)return null;let X=EZ($,J+1,Z);if(!X)return null;let Y=iV($,X.end,Z);return{end:Y?.end??X.end,nodes:[E1({alt:PZ($.slice(M+b3.length,J)),title:X.title,url:X.url,width:Y?.width??null})]}}function aV($,M,Z,J){if($[M]!==T3||$.startsWith(b3,M-1))return null;let X=WZ($,M,Z);if(X<0||$[X+1]!==_Z)return null;let Y=EZ($,X+1,Z);if(!Y)return null;return{end:Y.end,nodes:[r1({children:y2($.slice(M+T3.length,X),J),title:Y.title,url:Y.url})]}}function EZ($,M,Z){let J=w3($,M+1,Z),X=J;while(X<Z&&$[X]!==GZ&&$[X]!==FZ){if($[X]===j3){X+=2;continue}X+=1}if(X===J)return null;let Y=tV($.slice(J,X));J=w3($,X,Z);let Q=null;if(J<Z&&$[J]==='"'){let K=BZ($,'"',J+1,Z);if(K<0)return null;Q=$.slice(J+1,K).replace(HZ,"$1"),J=w3($,K+1,Z)}if($[J]!==GZ)return null;return{end:J+1,title:Q,url:Y}}function iV($,M,Z){let J=vV.exec($.slice(M,Z));if(!J)return null;return{end:M+J[0].length,width:Number(J[1])}}function sV($,M,Z,J){if(!$.startsWith(N1,M))return oV($,M,Z);let X=$.indexOf(m4,M+N1.length);if(X<0||X>=Z)return{end:M+N1.length,nodes:[L3("html",N1)]};return{end:X+m4.length,nodes:O3($,M+N1.length,X,[...J,"underline"])}}function oV($,M,Z){if($[M]!=="<")return null;let J=$.indexOf(">",M+1);if(J<0||J>=Z)return null;return{end:J+1,nodes:[L3("html",$.slice(M,J+1))]}}function nV($,M,Z){if($[M]!==zZ||!mV.test($[M+1]??""))return null;let J=M+2;while(J<Z&&fV.test($[J]??""))J+=1;let X=NZ($,J,Z,"[","]"),Q=NZ($,X?.end??J,Z,"{","}")?.end??X?.end??J;return{end:Q,nodes:[L3("textDirective",$.slice(M,Q))]}}function NZ($,M,Z,J,X){if($[M]!==J)return null;let Y=yZ($,X,M+1,Z);if(Y<0)return null;return{end:Y+1}}function WZ($,M,Z){return yZ($,"]",M+1,Z)}function yZ($,M,Z,J){return BZ($,M,Z,J)}function BZ($,M,Z,J){for(let X=Z;X<J;X+=1){if($[X]===j3){X+=1;continue}if($[X]===M)return X}return-1}function w3($,M,Z){while(M<Z&&$[M]===FZ)M+=1;return M}function PZ($){return $.replace(uV,"$1")}function tV($){return $.replace(HZ,"$1")}var eV=/^:?-+:?$/;function TZ($,M){let Z=bZ($),J=$.lines[$.index+1]??"",X=C3(Z,M),Y=C3(J,M);if(!wZ(X)||!R3(Y))return null;let Q=[M8(X)],K=$U(Y);$.index+=2;while($.index<$.lines.length){let q=bZ($),D=C3(q,M);if(MU(q)||!wZ(D))break;Q.push(M8(D)),$.index+=1}return y1({align:K,rows:Q.map((q)=>c1({cells:q.map((D)=>J1({children:y2(D)}))}))})}function wZ($){let M=$.trim();return/\|/.test($)&&M.startsWith("|")&&M.endsWith("|")}function R3($){let M=M8($);return M.length>0&&M.every((Z)=>eV.test(Z.trim()))}function $U($){return M8($).map((M)=>{let Z=M.trim();if(Z.startsWith(":")&&Z.endsWith(":"))return"center";if(Z.startsWith(":"))return"left";if(Z.endsWith(":"))return"right";return null})}function M8($){return $.trim().slice(1,-1).split("|").map((Z)=>Z.trim())}function bZ($){return $.lines[$.index]??""}function MU($){return $.trim()===""}function C3($,M){return $.slice(M)}var ZU=3,JU=/^\d+\.$/,XU=/^\[( |x|X)\](?:\s|$)/,jZ=/^```([^\s`]*)?(?:\s+(.*))?$/,OZ=/^::(?!:)[A-Za-z][-\w]*/,LZ=/^(#{1,6})\s+(.*)$/,YU=/\s+#+\s*$/u,QU=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,KU=/^(\*\s*){3,}$/,DU=/^(-\s*){3,}$/,qU=/^(_\s*){3,}$/;function J8($,M,Z){let J=[];while($.index<$.lines.length){let X=N0($);if($.index===$.lines.length-1&&X==="")break;if(v4(X)){$.index+=1;continue}if(B2(X)>M+ZU)break;let Q=VU($,M,Z);if(!Q)break;J.push(Q)}return J}function VU($,M,Z){return UU($,M,Z)??GU($,M)??AU($,M)??_U($,M)??FU($,M)??zU($,M)??TZ($,M)??HU($,M,Z)??EU($,M)??WU($,M)}function UU($,M,Z){let J=N0($);if(!BU(J,M))return null;let X=[];while($.index<$.lines.length){let Y=N0($),Q=B2(Y);if(v4(Y)){X.push(""),$.index+=1;continue}if(Q<M)break;let K=R0(Y,M);if(!K.startsWith(W2))break;let q=K.slice(1);if(q.startsWith(" "))q=q.slice(1);X.push(q),$.index+=1}return W0({children:J8({index:0,lines:X},0,Z)})}function GU($,M){let Z=N0($),J=R0(Z,M),X=jZ.exec(J);if(!X)return null;$.index+=1;let Y=[];while($.index<$.lines.length){let Q=N0($),K=R0(Q,M);if(K.trim()===f4){$.index+=1;break}Y.push(K),$.index+=1}return w8({language:X[1]?X[1]:null,meta:X[2]?X[2]:null,source:Y.join(o)})}function AU($,M){let Z=N0($),J=R0(Z,M),X=P3.exec(J);if(!X)return null;let Y=X[1],Q=[];$.index+=1;while($.index<$.lines.length){let K=N0($),q=R0(K,M);if($.index+=1,q.trim()===t5)break;Q.push(q)}return P9({attributes:NU(X[2]??""),body:Q.join(o),name:Y})}function NU($){let M=$.trim();if(M.startsWith("{")&&M.endsWith("}"))return M.slice(1,-1);return M}function _U($,M){let Z=N0($),J=R0(Z,M);if(!OZ.test(J))return null;return $.index+=1,X5({originalType:"leafDirective",source:J})}function FU($,M){let Z=N0($),J=LZ.exec(R0(Z,M));if(!J)return null;return $.index+=1,$5({children:y2(J[2].replace(YU,"")),depth:J[1].length})}function zU($,M){let Z=R0(N0($),M).trim();if(!CZ(Z))return null;return $.index+=1,J5()}function HU($,M,Z){let J=Z8(N0($),M);if(!J)return null;let X=[],Y=!1;while($.index<$.lines.length){let Q=N0($),K=Z8(Q,M);if(!K||K.ordered!==J.ordered)break;$.index+=1;let q=[K.content],D=!1;while($.index<$.lines.length){let V=N0($),G=B2(V);if(v4(V)){let U=bU($.lines,$.index+1);if(U<0||B2($.lines[U]??"")<=M)break;D=!0,q.push(""),$.index+=1;continue}if(G<K.contentIndent)break;if(G===M&&Z8(V,M))break;q.push(PU(V,K.contentIndent)),$.index+=1}Y||=D,X.push(s0({checked:K.checked,children:yU(q,Z),spread:D}))}return W1({items:X,ordered:J.ordered,spread:Y,start:J.ordered&&Z.preserveOrderedListStart?J.start??1:null})}function EU($,M){let Z=R0(N0($),M).trim();if(!RZ(Z))return null;return $.index+=1,X5({originalType:"html",source:Z})}function WU($,M){let Z=[];while($.index<$.lines.length){let J=N0($),X=B2(J);if(v4(J))break;if(X<M)break;let Y=R0(J,M);if(Z.length>0&&wU(J,Y,M))break;Z.push(Y),$.index+=1}return H1({children:y2(Z.join(o))})}function yU($,M){let Z=J8({index:0,lines:$},0,M);if(Z.length>0)return Z;return[H1({children:[]})]}function Z8($,M){let Z=QU.exec($);if(!Z||Z[1].length!==M)return null;let J=Z[2],X=JU.test(J),Y=X?Number(J.slice(0,-1)):null,Q=Z[3]??"",K=null;if(XU.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?Z[0].length-Z[1].length-Z[2].length-Q.length:Z[0].length-Z[1].length-Z[2].length;return{checked:K,content:Q,contentIndent:M+Z[2].length+q,ordered:X,start:Y}}function BU($,M){return R0($,M).startsWith(W2)}function R0($,M){return $.slice(M)}function PU($,M){let Z=B2($);if(Z>=M)return $.slice(M);return $.trim()===""?"":$.slice(Math.min(Z,M))}function CZ($){return KU.test($)||DU.test($)||qU.test($)}function RZ($){return $.startsWith("<")&&$.endsWith(">")}function B2($){let M=0;while(M<$.length&&$[M]===" ")M+=1;return M}function wU($,M,Z){return M.startsWith(W2)||jZ.test(M)||P3.test(M)||OZ.test(M)||LZ.test(M)||CZ(M.trim())||R3(M)||Z8($,Z)!==null||RZ(M.trim())}function N0($){return $.lines[$.index]??""}function v4($){return $.trim()===""}function bU($,M){for(let Z=M;Z<$.length;Z+=1)if(!v4($[Z]??""))return Z;return-1}function kZ($){let M=$.at(-1),Z=M&&SZ(M)?M:null;return{blocks:$.filter((X)=>!SZ(X)),comments:Z?TU(Z.body):[]}}function TU($){let M;try{M=JSON.parse($)}catch{return[]}if(!Array.isArray(M))return[];return M.flatMap((Z)=>{let J=I8(Z);return J?[J]:[]})}function SZ($){return $.type==="directive"&&$.name===e5}var mZ="---";function u4($,M={}){let J={index:0,lines:$.replace(/\r\n/g,o).split(o)},X=jU(J),Y=J8(J,0,M),{comments:Q,blocks:K}=kZ(Y);return a1(K,Q,X)}function jU($){if($.lines[0]!==mZ)return;for(let M=1;M<$.lines.length;M+=1)if($.lines[M]===mZ){let Z=$.lines.slice(0,M+1).join(o);return $.index=M+1,Z}return}var P2=`
|
|
27
|
-
|
|
28
|
-
`,OU="-",LU=".",CU="***",RU=" ",S3=3,SU=5,kU=4,fZ=2,mU=2,fU=1,vU=/([\\`*_[\]])/g,uU=/([\\)&])/g,hU=/(["\\])/g;function X8($,M={}){if($.blocks.length===0&&$.comments.length===0&&$.frontMatter===void 0)return"";let Z=[];if($.frontMatter!==void 0)Z.push($.frontMatter);if($.blocks.length>0)Z.push(k3($.blocks,M));if($.comments.length>0)Z.push(ZG($.comments));let J=Z.join(P2);return J.endsWith(o)?J:`${J}${o}`}function k3($,M={}){return $.map((Z)=>Y8(Z,0,M)).join(P2)}function Y8($,M,Z){let J=_1(M);switch($.type){case"blockquote":return IU($,M,Z);case"code":return gU($,M);case"directive":return JG($,M);case"heading":return uZ($,M);case"list":return pU($,M,Z);case"listItem":return hZ($,M,!1,1,Z);case"paragraph":return`${J}${m3(f1($.children))}`;case"table":return xU($,M,Z);case"thematicBreak":return`${J}${CU}`;case"unsupported":return M===0?$.source:pZ($.source,M)}}function IU($,M,Z){let J=$.children.map((Y)=>Y8(Y,0,Z)).join(P2),X=_1(M);return J.split(o).map((Y)=>`${X}${W2}${Y.length>0?` ${Y}`:""}`).join(o)}function gU($,M){let Z=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),J=_1(M),X=`${J}${f4}${Z?Z:""}`,Y=$.source.length>0?$.source.split(o).map((Q)=>`${J}${Q}`).join(o):J;return`${X}${o}${Y}${o}${J}${f4}`}function uZ($,M){let Z=m3(f1($.children)),J=`${_1(M)}${"#".repeat($.depth)}`;return Z.length>0?`${J} ${Z}`:J}function pU($,M,Z){let J=$.start??1;return $.items.map((X)=>hZ(X,M,$.ordered,J,Z)).join($.spread?P2:o)}function hZ($,M,Z,J,X){let Y=Z?`${J}${LU}`:OU,Q=$.checked===null?"":`[${$.checked?"x":" "}] `,K=`${_1(M)}${Y} ${Q}`,q=M+Y.length+1,D=$.children;if(D.length===0)return Q.length>0?K:K.trimEnd();let[V,...G]=D,U=lU(V,K,Q.length>0,X),A=G.map((_)=>Y8(_,q,X)).join($.spread?P2:o);if(!A)return U;return`${U}${$.spread?P2:o}${A}`}function lU($,M,Z,J){switch($.type){case"paragraph":{let X=m3(f1($.children));if(X.length===0)return Z?M:M.trimEnd();return`${M}${X}`}case"heading":return`${M}${uZ($,0)}`;case"directive":case"unsupported":{let X=$.type==="directive"?f3($):$.source,[Y,...Q]=X.split(o);return[M+Y,...Q.map((K)=>`${_1(M.length)}${K}`)].join(o)}default:{let X=M.length;return`${M.trimEnd()}${o}${Y8($,X,J)}`}}}function xU($,M,Z){let J=$.rows.map((V)=>V.cells.map((G)=>f1(G.children))),X=Math.max(1,...J.map((V)=>V.length)),Y=J[0]??[],Q=Array.from({length:X},(V,G)=>Math.max(S3,aU($.align[G]),...Z.padTableColumns?J.map((U)=>U[G]?.length??0):[Y[G]?.length??0])),K=dU(Q,$.align,M),q=vZ(Y,Q,$.align,M,Z),D=J.slice(1).map((V)=>vZ(V,Q,$.align,M,Z));return[q??rU(Q,M),K,...D].join(o)}function vZ($,M,Z,J,X){let Y=M.map((Q,K)=>{let q=$[K]??"";if(!X.padTableColumns)return q;return iU(q,Q,Z[K])});return`${" ".repeat(J)}| ${Y.join(" | ")} |`}function dU($,M,Z){let J=$.map((X,Y)=>cU(M[Y],X));return`${" ".repeat(Z)}| ${J.join(" | ")} |`}function rU($,M){return`${_1(M)}| ${$.map((Z)=>"".padEnd(Z," ")).join(" | ")} |`}function cU($,M){let Z=Math.max(S3,M-($==="center"?mU:$?fU:0));switch($){case"center":return`:${"-".repeat(Math.max(1,Z))}:`;case"left":return`:${"-".repeat(Math.max(fZ,Z))}`;case"right":return`${"-".repeat(Math.max(fZ,Z))}:`;default:return"-".repeat(Z)}}function aU($){return $==="center"?SU:$?kU:S3}function iU($,M,Z){if(Z==="right")return $.padStart(M," ");return $.padEnd(M," ")}function f1($){return oU($).map((M)=>sU(M)).join("")}function m3($){return $.replace(/^ +/gm,(M)=>RU.repeat(M.length))}function sU($){switch($.type){case"break":return o;case"image":return XG($);case"inlineCode":return eU($.code);case"link":return YG($);case"text":return tU(IZ($.text),$.marks);case"unsupported":return $.source}}function oU($){let M=[];for(let Z of $){let J=M.at(-1);if(J?.type==="text"&&Z.type==="text"&&nU(J.marks,Z.marks)){M[M.length-1]={...J,text:J.text+Z.text};continue}M.push(Z)}return M}function nU($,M){return $.length===M.length&&$.every((Z,J)=>Z===M[J])}function tU($,M){return M.reduce((Z,J)=>{switch(J){case"bold":return`**${Z}**`;case"italic":return`*${Z}*`;case"strikethrough":return`~~${Z}~~`;case"underline":return`${N1}${Z}${m4}`}},$)}function eU($){let M=0,Z=0;for(let Q of $){if(Q==="`"){if(Z+=1,Z>M)M=Z;continue}Z=0}let J=M>0?M+1:1,X="`".repeat(J),Y=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${X}${Y}${X}`}function IZ($){return $.replace(vU,"\\$1")}function $G($){return $.replace(uU,"\\$1")}function MG($){return $?` "${$.replace(hU,"\\$1")}"`:""}function ZG($){return f3({attributes:"",body:JSON.stringify($,null,2),name:e5})}function JG($,M){let Z=f3($);return M===0?Z:pZ(Z,M)}function f3($){let M=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${M}${o}${$.body}${o}${t5}`}function XG($){let M=IZ($.alt??""),Z=gZ($.url,$.title),J=$.width?`{width=${$.width}}`:"";return`![${M}]${Z}${J}`}function YG($){return`[${f1($.children)}]${gZ($.url,$.title)}`}function gZ($,M){return`(${$G($)}${MG(M)})`}function _1($){return" ".repeat($)}function pZ($,M){let Z=_1(M);return $.split(o).map((J)=>`${Z}${J}`).join(o)}function v3($){if($.length===0)return{kind:"text",text:""};let{blocks:M}=u4($);if(K5(M))return{kind:"text",text:M[0]?.plainText??""};if(M.length===1&&M[0]?.type==="paragraph")return{kind:"inlines",inlines:M[0].children};return{kind:"blocks",blocks:M}}function Q8($){switch($.kind){case"text":return $.text;case"inlines":return f1($.inlines);case"blocks":return k3($.blocks)}}import{createContext as QG,useContext as KG}from"react";import{createPortal as DG}from"react-dom";import{jsx as dZ}from"react/jsx-runtime";var lZ=QG(void 0);function xZ({children:$,themeStyles:M}){return dZ(lZ.Provider,{value:M,children:$})}function K8({children:$}){let M=KG(lZ);if(typeof document>"u")return null;return DG(dZ("div",{className:"documint-overlay",style:{display:"contents",...M},children:$}),document.body)}import{useEffect as D8,useRef as XJ,useState as v1}from"react";import{forwardRef as VG,useCallback as w2,useEffect as UG,useImperativeHandle as GG,useLayoutEffect as AG,useMemo as NG,useRef as aZ,useState as u3}from"react";var qG=["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 rZ($,M,{topGap:Z=8}={}){if(!$.isConnected)return null;let J=getComputedStyle($),X=document.createElement("div");for(let D of qG)X.style.setProperty(D,J.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(J.lineHeight)||Y.offsetHeight,q={left:Q.left+Y.offsetLeft+parseFloat(J.borderLeftWidth)-$.scrollLeft,top:Q.top+Y.offsetTop+parseFloat(J.borderTopWidth)+K+Z-$.scrollTop};return document.body.removeChild(X),q}import{jsx as S0,jsxs as iZ,Fragment as PG}from"react/jsx-runtime";var _G=240,FG="documint-leaf-menu-item documint-completion-item",h4=VG(function({actions:M,completionSources:Z,onChange:J,placeholder:X,readOnly:Y=!1,rows:Q=3,value:K},q){let D=aZ(null);GG(q,()=>D.current,[]);let V=NG(()=>WG(Z),[Z]),[G,U]=u3(null),[A,_]=u3(0),[N,z]=u3(null),E=w2((y,b)=>{if(!V.length){U(null);return}let H=yG(y,b,V);if(!H){U(null);return}U(H),_(0)},[V]),L=w2((y)=>{let b=y.currentTarget.value,H=y.currentTarget.selectionEnd??b.length;J(b),E(b,H)},[J,E]),W=w2((y)=>{let b=y.currentTarget;E(b.value,b.selectionEnd??b.value.length)},[E]),R=w2(()=>{U(null)},[]),S=w2((y)=>{if(!D.current||!G)return;let H=`${G.trigger}${y.label} `,j=K.slice(0,G.triggerStart),B=K.slice(G.caret),P=j+H+B,F=G.triggerStart+H.length;J(P),U(null),requestAnimationFrame(()=>{let C=D.current;if(!C)return;C.focus(),C.setSelectionRange(F,F)})},[G,J,K]),I=w2((y)=>{if(G&&G.matches.length>0){if(y.key==="ArrowDown"){y.preventDefault(),y.stopPropagation(),_((b)=>(b+1)%G.matches.length);return}if(y.key==="ArrowUp"){y.preventDefault(),y.stopPropagation(),_((b)=>(b-1+G.matches.length)%G.matches.length);return}if(y.key==="Enter"||y.key==="Tab"){y.preventDefault(),y.stopPropagation();let b=G.matches[A];if(b)S(b);return}if(y.key==="Escape"){y.preventDefault(),y.stopPropagation(),U(null);return}}if(y.key==="Escape"&&M.kind==="edit")y.preventDefault(),M.onCancel()},[M,G,A,S]);return AG(()=>{if(!G){z(null);return}let y=()=>{let b=D.current;if(!b)return;z(rZ(b,G.triggerStart))};return y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[G]),iZ("div",{className:"documint-leaf-input-field",children:[S0("textarea",{className:"documint-leaf-input",onBlur:R,onChange:L,onKeyDown:I,onSelect:W,placeholder:X,readOnly:Y,ref:D,rows:Q,value:K}),zG(M),G&&N&&G.matches.length>0?S0(K8,{children:S0(HG,{activeIndex:A,left:N.left,matches:G.matches,onHover:_,onSelect:S,top:N.top})}):null]})});function zG($){if($.kind==="edit")return iZ(PG,{children:[S0(h3,{className:"documint-leaf-input-cancel",icon:k4,label:"Cancel editing",onClick:$.onCancel}),S0(h3,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:k1,label:"Save",onClick:$.onSave})]});return S0(h3,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:G1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit})}function h3({className:$,disabled:M=!1,icon:Z,iconSize:J=14,label:X,onClick:Y}){return S0("button",{"aria-label":X,className:`documint-leaf-action ${$}`,disabled:M,onClick:Y,title:X,type:"button",children:S0(Z,{size:J,strokeWidth:2.2})})}function HG({activeIndex:$,left:M,matches:Z,onHover:J,onSelect:X,top:Y}){let Q=aZ(null);return UG(()=>{let K=Q.current;if(!K)return;let q=K.children[$];if(q instanceof HTMLElement)q.scrollIntoView({block:"nearest"})},[$]),S0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Q,role:"listbox",style:{position:"fixed",left:M,top:Y,maxHeight:_G,overflowY:"auto"},children:Z.map((K,q)=>{let D=q===$;return S0("button",{"aria-selected":D,className:`${FG}${D?" is-active":""}`,onPointerDown:EG,onPointerEnter:()=>J(q),onClick:()=>X(K),role:"option",type:"button",children:S0("span",{children:K.label})},K.label)})})}function EG($){$.preventDefault()}function WG($){if(!$?.length)return[];return $.map((M)=>({trigger:M.trigger,items:[...M.items].sort((Z,J)=>Z.label.localeCompare(J.label,void 0,{sensitivity:"base"}))}))}function yG($,M,Z){for(let J=M-1;J>=0;J-=1){let X=$[J];if(cZ(X))return null;let Y=Z.find((K)=>K.trigger===X);if(!Y)continue;if(J>0&&!cZ($[J-1]))return null;let Q=$.slice(J+1,M);return{trigger:Y.trigger,query:Q,triggerStart:J,caret:M,matches:BG(Y.items,Q)}}return null}function cZ($){return $===void 0||$===" "||$===`
|
|
29
|
-
`||$==="\t"}function BG($,M){if(!M)return $;let Z=M.toLowerCase();return $.filter((J)=>J.label.toLowerCase().includes(Z))}import{Fragment as bG}from"react";function I3($,M){if(!M?.length||!M.some((Q)=>$.includes(Q.trigger)))return[{kind:"text",text:$}];let Z=new Map;for(let Q of M){let K=[...Q.items].sort((q,D)=>D.label.length-q.label.length);Z.set(Q.trigger,K)}let J=[],X=0,Y=0;while(X<$.length){let Q=$[X],K=Z.get(Q);if(K!==void 0&&(X===0||wG($[X-1]))){let D=K.find((V)=>$.startsWith(V.label,X+1));if(D){if(X>Y)J.push({kind:"text",text:$.slice(Y,X)});J.push({kind:"token",trigger:Q,label:D.label,id:D.id}),X+=1+D.label.length,Y=X;continue}}X+=1}if(Y<$.length)J.push({kind:"text",text:$.slice(Y)});return J}function g3($,M){let Z=[],J=new Set;for(let X of I3($,M)){if(X.kind!=="token"||X.trigger!=="@"||!X.id)continue;if(J.has(X.id))continue;J.add(X.id),Z.push(X.id)}return Z}function wG($){return $===void 0||$===" "||$===`
|
|
30
|
-
`||$==="\t"}import{jsx as sZ,jsxs as jG}from"react/jsx-runtime";function p3({value:$,completionSources:M,onEdit:Z}){return sZ("p",{onDoubleClick:Z,children:TG($,M)})}function TG($,M){let Z=I3($,M);if(Z.length===1&&Z[0].kind==="text")return $;return Z.map((J,X)=>J.kind==="token"?jG("span",{className:"documint-mention",children:[J.trigger,J.label]},X):sZ(bG,{children:J.text},X))}import{Children as oZ,isValidElement as nZ,useEffect as OG,useRef as LG,useState as CG}from"react";import{jsx as V0,jsxs as d3}from"react/jsx-runtime";var l3=($)=>{$.preventDefault()},x3=($)=>$.isPrimary&&$.button===0;function RG({children:$}){return V0("div",{className:"documint-leaf-toolbar",children:oZ.map($,SG)})}function SG($){if(!nZ($))return null;if($.type===eZ){let M=$.props;return V0(tZ,{children:V0(kG,{...M})})}if($.type===$J){let{className:M}=$.props;return V0("div",{className:I4("documint-leaf-toolbar-divider",M)})}if($.type===MJ){let M=$.props;return V0(mG,{...M})}return null}function kG({active:$=!1,className:M,disabled:Z=!1,icon:J,label:X,onClick:Y}){return V0("button",{"aria-label":X,className:I4("documint-leaf-toolbar-button",$?"active":null,M),disabled:Z,onPointerDown:(Q)=>{if(l3(Q),!Z&&x3(Q))Y()},title:X,type:"button",children:V0(J,{size:15,strokeWidth:2.2})})}function mG({children:$,className:M,icon:Z,label:J,onSelect:X}){let Y=LG(null),[Q,K]=CG(!1);return OG(()=>{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]),V0(tZ,{children:d3("div",{className:"documint-leaf-toolbar-menu-shell",ref:Y,children:[V0(fG,{className:M,icon:Z,isOpen:Q,label:J,onClick:()=>K((q)=>!q)}),Q?V0("div",{className:"documint-leaf-menu",role:"menu",children:oZ.map($,(q)=>vG(q,(D)=>{K(!1),X(D)}))}):null]})})}function fG({className:$,icon:M,isOpen:Z,label:J,onClick:X}){return d3("button",{"aria-expanded":Z,"aria-haspopup":"menu","aria-label":J,className:I4("documint-leaf-toolbar-button",Z?"active":null,$),onPointerDown:(Y)=>{if(l3(Y),x3(Y))X()},title:J,type:"button",children:[V0(M,{size:15,strokeWidth:2.2}),V0(z4,{className:I4("documint-leaf-toolbar-menu-chevron",Z?"is-open":null),size:13,strokeWidth:2.2})]})}function vG($,M){if(!nZ($))return null;if($.type===JJ){let{className:Q}=$.props;return V0("div",{className:I4("documint-leaf-menu-divider",Q),role:"separator"})}if($.type!==ZJ)return null;let{disabled:Z=!1,icon:J,text:X,value:Y}=$.props;return d3("button",{className:"documint-leaf-menu-item",disabled:Z,onPointerDown:(Q)=>{if(l3(Q),!Z&&x3(Q))M(Y)},role:"menuitem",type:"button",children:[V0(J,{size:15,strokeWidth:2.2}),V0("span",{children:X})]})}function I4(...$){return $.filter(Boolean).join(" ")}function tZ({children:$}){return V0("div",{className:"documint-leaf-toolbar-group",children:$})}function eZ($){return null}function $J($){return null}function MJ($){return null}function ZJ($){return null}function JJ($){return null}var r=Object.assign(RG,{Button:eZ,Divider:$J,Menu:MJ,MenuDivider:JJ,MenuItem:ZJ});import{jsx as n,jsxs as x0,Fragment as gG}from"react/jsx-runtime";var uG=!1,hG=220,u1=()=>{};function r3($){let M=$.mode==="create",Z=$.mode==="create"?$:null,J=$.mode==="thread"?$:null,X=$.canEdit,Y=$.link,Q=J?.thread??null,K=Q?.comments??[],q=K[0]??null,D=Q?X1(Q):!1,V=J?.animateInitialComment??!1,[G,U]=v1(null),[A,_]=v1(""),[N,z]=v1(""),[E,L]=v1(""),[W,R]=v1(!V),[S,I]=v1(uG),[y,b]=v1(!1),H=XJ(null),j=XJ(null),B=$.mentionSources,P=Q?c8(Q):null,F=P?YJ(P):"",C=X&&!D,u=C&&A.trim().length>0,h=C&&N.trim().length>0,g=X&&E.trim().length>0,w=M||y,T=!M||S,k=!M&&Boolean(Q),m=Boolean(q),a=M?S:!0,l=J?.onDeleteComment??u1,F0=J?.onDeleteThread??u1,c0=J?.onToggleResolved??u1,k0=Z?.activeMarks??[],m0=Z?.onToggleBold??u1,a0=Z?.onToggleItalic??u1,z8=Z?.onToggleStrikethrough??u1,H8=Z?.onToggleUnderline??u1,a4=X?M?"Add a comment":"Reply to this comment":"Comment editing is disabled",E8=M?E:N;D8(()=>{if(G!==null&&(G<0||G>=K.length))U(null),_("")},[K.length,G]),D8(()=>{if(!m||!V){R(!0);return}R(!1);let i=requestAnimationFrame(()=>{R(!0)});return()=>{cancelAnimationFrame(i)}},[V,q,m]),D8(()=>{if(!J||!V){b(!1);return}b(!0);let i=window.setTimeout(()=>{b(!1)},hG);return()=>{window.clearTimeout(i)}},[V,J]),D8(()=>{if(!M||!S||!X)return;let i=requestAnimationFrame(()=>{j.current?.focus()});return()=>{cancelAnimationFrame(i)}},[X,M,S]);let O2=()=>{U(null),_("")},i4=(i,s4)=>{if(!k||!C)return;U(i),_(s4)},f0=(i)=>{if(!J)return;J.onEditComment(i,A),O2()},P0=()=>{if(!J)return;J.onReply(N),z("")},g1=()=>{if(!Z||!g)return;Z.onCreateThread(E),L("")},W8=w?`documint-comment-leaf documint-comment-leaf-create${a?" is-expanded":""}`:"documint-comment-leaf",p1=k||m||T?n(IG,{canCreate:g,canEdit:X,canMutateThread:C,canReply:h,canSaveEditedComment:u,comments:K,composerRef:j,editDraft:A,editingCommentIndex:G,isComposerVisible:T,isInitialCommentVisible:W,isResolved:D,link:Y,mentionSources:B,mode:$.mode,onBeginEditingComment:i4,onCancelEditing:O2,onChangeCreateDraft:L,onChangeEditDraft:_,onChangeReplyDraft:z,onDeleteComment:l,onDeleteThread:F0,onSubmitCreate:g1,onSubmitEditedComment:f0,onSubmitReply:P0,onToggleResolved:c0,rootComment:q,showRootComment:m,showThreadChrome:k,threadAge:F,composerPlaceholder:a4,composerValue:E8}):null;return n("div",{className:W8,ref:H,children:x0("div",{className:w?"documint-comment-leaf-create-shell":void 0,children:[w?x0(r,{children:[n(r.Button,{className:"documint-comment-leaf-create-button",icon:L4,label:"Add comment",onClick:()=>I(!0)}),n(r.Divider,{className:"documint-comment-leaf-create-divider"}),n(r.Button,{active:k0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:F4,label:"Bold",onClick:m0}),n(r.Button,{active:k0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:b4,label:"Italic",onClick:a0}),n(r.Button,{active:k0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:S4,label:"Underline",onClick:H8}),n(r.Button,{active:k0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:C4,label:"Strikethrough",onClick:z8})]}):null,n("div",{className:w?"documint-comment-leaf-create-content":void 0,children:p1})]})})}function IG({canCreate:$,canEdit:M,canMutateThread:Z,canReply:J,canSaveEditedComment:X,comments:Y,composerRef:Q,editDraft:K,editingCommentIndex:q,isComposerVisible:D,isInitialCommentVisible:V,isResolved:G,link:U,mentionSources:A,mode:_,onBeginEditingComment:N,onCancelEditing:z,onChangeCreateDraft:E,onChangeEditDraft:L,onChangeReplyDraft:W,onDeleteComment:R,onDeleteThread:S,onSubmitCreate:I,onSubmitEditedComment:y,onSubmitReply:b,onToggleResolved:H,rootComment:j,showRootComment:B,showThreadChrome:P,threadAge:F,composerPlaceholder:C,composerValue:u}){return x0(gG,{children:[P?x0("div",{className:"documint-comment-leaf-header",children:[n("span",{className:"documint-comment-leaf-age",children:F}),x0("div",{className:"documint-comment-leaf-actions",children:[n("button",{className:"documint-leaf-action","aria-label":G?"Reopen comment":"Resolve comment",disabled:!M,onClick:H,title:G?"Reopen comment":"Resolve comment",type:"button",children:n(k1,{size:14,strokeWidth:2.2})}),n("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!M,onClick:S,title:"Delete comment thread",type:"button",children:n(T0,{size:14,strokeWidth:2.2})})]})]}):null,P&&U?x0("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,x0("div",{className:`documint-comment-thread${B?"":" is-empty"}`,children:[n("article",{className:B?`documint-comment-message documint-comment-message-root${V?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:j?n(p3,{completionSources:A,onEdit:()=>N(0,j.body),value:j.body}):null}),Y.slice(1).map((h,g)=>{let w=g+1,T=q===w;return x0("article",{className:"documint-comment-message",children:[!T?x0("div",{className:"documint-comment-message-meta",children:[n("span",{children:YJ(h.updatedAt)}),Z?x0("div",{className:"documint-comment-leaf-actions",children:[n("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!Z,onClick:()=>{N(w,h.body)},title:"Edit comment",type:"button",children:n(m1,{size:14,strokeWidth:2.2})}),n("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!Z,onClick:()=>R(w),title:"Delete comment",type:"button",children:n(T0,{size:14,strokeWidth:2.2})})]}):null]}):null,T?n(h4,{actions:{kind:"edit",onCancel:z,onSave:()=>y(w),saveDisabled:!X},completionSources:A,onChange:L,readOnly:!M,rows:3,value:K}):n(p3,{completionSources:A,onEdit:()=>N(w,h.body),value:h.body})]},`${h.updatedAt}:${w}`)})]}),n("div",{className:`documint-comment-reply${P?"":" is-standalone"}${D?" is-visible":""}`,children:n(h4,{actions:_==="create"?{kind:"compose",onSubmit:I,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:b,submitDisabled:!J,submitLabel:"Reply"},completionSources:A,onChange:_==="create"?E:W,placeholder:C,readOnly:!M,ref:Q,rows:3,value:u})})]})}function YJ($){let M=new Date($);if(Number.isNaN(M.getTime()))return $;let Z=M.getTime()-Date.now(),J=60000,X=60*J,Y=24*X,Q=7*Y,K=30*Y,q=365*Y,D=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(Z)<J)return"just now";if(Math.abs(Z)<X)return D.format(Math.round(Z/J),"minute");if(Math.abs(Z)<Y)return D.format(Math.round(Z/X),"hour");if(Math.abs(Z)<Q)return D.format(Math.round(Z/Y),"day");if(Math.abs(Z)<q)return D.format(Math.round(Z/K),"month");return D.format(Math.round(Z/q),"year")}import{jsx as d0,jsxs as xG}from"react/jsx-runtime";var pG=[{icon:H4,label:"Heading 1",text:"# "},{icon:E4,label:"Heading 2",text:"## "},{icon:W4,label:"Heading 3",text:"### "},{icon:y4,label:"Heading 4",text:"#### "},{icon:B4,label:"Heading 5",text:"##### "},{icon:P4,label:"Heading 6",text:"###### "}],lG=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function QJ({onInsert:$,onInsertTable:M}){return xG(r,{children:[d0(r.Button,{icon:O4,label:"Insert bulleted list",onClick:()=>$("- ")}),d0(r.Button,{icon:T4,label:"Insert numbered list",onClick:()=>$("1. ")}),d0(r.Button,{icon:j4,label:"Insert task list",onClick:()=>$("- [ ] ")}),d0(r.Divider,{}),d0(r.Menu,{icon:w4,label:"Insert heading",onSelect:$,children:pG.map(({icon:Z,label:J,text:X})=>d0(r.MenuItem,{icon:Z,text:J,value:X},X))}),d0(r.Menu,{icon:A1,label:"Insert table",onSelect:(Z)=>M(Number(Z)),children:lG.map(({columns:Z,text:J})=>d0(r.MenuItem,{icon:A1,text:J,value:String(Z)},Z))}),d0(r.Divider,{}),d0(r.Button,{icon:R4,label:"Insert blockquote",onClick:()=>$("> ")})]})}import{jsx as c3,jsxs as dG}from"react/jsx-runtime";function KJ({anchor:$,children:M,status:Z="default"}){let J=!$.isSelection;return c3(K8,{children:dG("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[J?c3("div",{className:"documint-leaf-bridge"}):null,c3("div",{className:"documint-leaf-shell","data-status":Z,children:M})]})})}import{useEffect as DJ,useRef as rG,useState as qJ}from"react";import{jsx as e0,jsxs as a3}from"react/jsx-runtime";function VJ({canEdit:$,onDelete:M,onSave:Z,title:J,url:X}){let[Y,Q]=qJ(X),[K,q]=qJ(!1),D=rG(null),V=cG(),G=Y.trim(),U=$&&G.length>0,A=$&&!K,_=`${V}click to open`,N=`documint-link-leaf-row${K?" is-editing":""}`;return DJ(()=>{if(K)return;Q(X)},[K,X]),DJ(()=>{if(!K)return;D.current?.focus()},[K]),a3("div",{className:"documint-link-leaf",children:[J?e0("div",{className:"documint-link-leaf-title",children:J}):null,a3("div",{className:N,children:[K?e0(h4,{actions:{kind:"edit",onCancel:()=>{Q(X),q(!1)},onSave:()=>{Z(G),q(!1)},saveDisabled:!U},onChange:Q,readOnly:!$,ref:D,rows:3,value:Y}):e0("div",{className:"documint-link-leaf-url",children:X}),A?a3("div",{className:"documint-link-leaf-actions",children:[e0("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Q(X),q(!0)},title:"Edit link",type:"button",children:e0(m1,{size:14,strokeWidth:2.2})}),e0("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:M,title:"Remove link",type:"button",children:e0(T0,{size:14,strokeWidth:2.2})})]}):null]}),e0("div",{className:"documint-link-leaf-divider"}),e0("div",{className:"documint-link-leaf-hint",children:_})]})}function cG(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsx as $1,jsxs as o3}from"react/jsx-runtime";var aG=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],iG=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],i3={text:"Delete column",value:"delete"},s3={text:"Delete row",value:"delete"},UJ={text:"Delete table",value:"delete"};function GJ({canDeleteColumn:$,canDeleteRow:M,onDeleteColumn:Z,onDeleteRow:J,onDeleteTable:X,onInsertColumn:Y,onInsertRow:Q}){return o3(r,{children:[o3(r.Menu,{icon:V1,label:"Column actions",onSelect:(K)=>{if(K===i3.value){Z();return}Y(K)},children:[aG.map(({text:K,value:q})=>$1(r.MenuItem,{icon:H2,text:K,value:q},q)),$1(r.MenuDivider,{}),$1(r.MenuItem,{disabled:!$,icon:T0,text:i3.text,value:i3.value})]}),o3(r.Menu,{icon:U1,label:"Row actions",onSelect:(K)=>{if(K===s3.value){J();return}Q(K)},children:[iG.map(({text:K,value:q})=>$1(r.MenuItem,{icon:H2,text:K,value:q},q)),$1(r.MenuDivider,{}),$1(r.MenuItem,{disabled:!M,icon:T0,text:s3.text,value:s3.value})]}),$1(r.Divider,{}),$1(r.Menu,{icon:A1,label:"Table actions",onSelect:()=>X(),children:$1(r.MenuItem,{icon:T0,text:UJ.text,value:UJ.value})})]})}import{useEffect as AJ,useEffectEvent as NJ,useLayoutEffect as _J,useMemo as sG,useRef as n3,useState as FJ}from"react";function q8($,M){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let Z=M[$.commentThreadIndex]??null;if(!Z)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:Z,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 oG=600,nG=530,b2=24;function HJ({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:Z,editorState:J,editorViewportState:X,getScrollTop:Y,layoutWidth:Q,onVisibilityChange:K,resources:q,scrollContentHeight:D,scrollTo:V,viewportHeight:G}){let U=sG(()=>J0(J),[J]),[A,_]=FJ(null),[N,z]=FJ(null),E=U.start.regionId===U.end.regionId&&U.start.offset===U.end.offset,L=n3(!0),W=n3(0),R=n3(null),S=NJ(()=>{K()}),I=NJ(()=>{W.current=typeof performance<"u"?performance.now():Date.now(),L.current=!0,S()});return _J(()=>{let y=tG({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:Z,normalizedSelection:U,state:J,viewport:X.get()});_((b)=>ZA(b,y)?b:y)},[$,M,Z,J,X]),_J(()=>{let y=q?XA(J,X.get(),U,q):null;z((b)=>YA(b,y)?b:y)},[J,X,U,q]),AJ(()=>{let y=J.selection.focus,b={layoutWidth:Q,offset:y.offset,regionId:y.regionId,scrollContentHeight:D,viewportHeight:G};if(JA(R.current,b))return;let H=y6(J,X.get(),y);if(!H)return;let j=Y(),B=j+b2,P=j+G-b2;if(H.top<B){let F=V(Math.max(0,H.top-b2));if(zJ(H,F,G,b2))R.current=b;return}if(H.top+H.height>P){let F=V(Math.max(0,H.top+H.height-G+b2));if(zJ(H,F,G,b2))R.current=b;return}R.current=b},[J,J.selection.focus.offset,J.selection.focus.regionId,X,Q,D,V,G]),AJ(()=>{if(L.current=!0,S(),!E||typeof window>"u")return;let y=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-W.current<oG){if(!L.current)L.current=!0,S();return}L.current=!L.current,S()},nG);return()=>{window.clearInterval(y)}},[E]),{imageAtCursor:N,leaf:A,isVisible:()=>L.current,markActivity:I}}function tG({canShowInsertionLeaf:$,canShowTableLeaf:M,commentState:Z,normalizedSelection:J,state:X,viewport:Y}){if(!Y)return null;let Q=X.selection.focus;if(J.start.regionId!==J.end.regionId||J.start.offset!==J.end.offset)return null;let K=$?MA(X,Y):null;if(K)return K;let q=M?eG(X,Y):null;if(q)return q;return q8(W6(X,Y,Q,Z.liveRanges),Z.threads)}function eG($,M){let Z=$.selection.focus,J=$.documentIndex.regionIndex.get(Z.regionId),X=J?$.documentIndex.tableCellIndex.get(J.id)??null:null;if(!J||!X)return null;let Y=$.documentIndex.blockIndex.get(J.blockId),Q=Y?.type==="table"?$.documentIndex.document.blocks[Y.rootIndex]:null;if(!Y||!Q||Q.type!=="table")return null;let K=t0($,M,Z),q=$A(M,J.id),D=Math.max(1,...Q.rows.map((V)=>V.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 $A($,M){let Z=$.layout.lines.find((J)=>J.regionId===M);return Z?Z.left:null}function MA($,M){let Z=$.selection.focus,J=$.documentIndex.regionIndex.get(Z.regionId);if(!J||J.blockType!=="paragraph"||J.text.length>0)return null;if(Z.offset!==0)return null;let X=$.documentIndex.blockIndex.get(J.blockId);if(!X||X.parentBlockId!==null)return null;let Y=t0($,M,Z);return Y?{kind:"insertion",left:Y.left,top:Y.top+Y.height}:null}function ZA($,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 JA($,M){return $?.layoutWidth===M.layoutWidth&&$.regionId===M.regionId&&$.offset===M.offset&&$.scrollContentHeight===M.scrollContentHeight&&$.viewportHeight===M.viewportHeight}function zJ($,M,Z,J){return $.top>=M+J&&$.top+$.height<=M+Z-J}function XA($,M,Z,J){if(!M)return null;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let X=L5($);if(!X)return null;let Y=V5($,M,J,X),Q=X.image?J.images.get(X.image.url)?.intrinsicWidth??null:null,K=$.selection.anchor.regionId;return Y?{bounds:Y,maxWidth:Q,regionId:K,run:X}:null}function YA($,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 t3,useRef as g4,useEffectEvent as e3}from"react";var QA=48;function EJ($,M,Z){let J=g4(null),X=g4(null),Y=g4(null),Q=g4(null),K=g4(1),q=e3((A,_)=>{if(!$)return;A.preventDefault(),A.stopPropagation(),A.currentTarget.setPointerCapture(A.pointerId),Q.current=A.pointerId,J.current=A.clientX,X.current=A.clientY,Y.current=$.run.image?.width??$.bounds.width,K.current=_}),D=e3((A)=>{if(Q.current!==A.pointerId||J.current===null||X.current===null||Y.current===null||!$?.run.image)return;let _=A.clientX-J.current,N=A.clientY-X.current,z=Math.min($.maxWidth??1/0,Math.max(QA,Math.round(Y.current+K.current*(_+N)))),E=PM(M,$.regionId,$.run,z);if(E)Z(E)}),V=e3((A)=>{if(A.currentTarget.hasPointerCapture(A.pointerId))A.currentTarget.releasePointerCapture(A.pointerId);Q.current=null,J.current=null,X.current=null,Y.current=null}),G=t3(()=>({onPointerDown:(A)=>q(A,-1),onPointerMove:D,onPointerUp:V,onPointerCancel:V}),[]),U=t3(()=>({onPointerDown:(A)=>q(A,1),onPointerMove:D,onPointerUp:V,onPointerCancel:V}),[]);return t3(()=>{if(!$)return null;let{bounds:A}=$;return{start:{left:A.left,top:A.top,props:G},end:{left:A.left+A.width,top:A.top+A.height,props:U}}},[$])}import{useEffect as WJ,useEffectEvent as yJ,useMemo as BJ,useRef as KA,useState as DA}from"react";function PJ($,M){let[Z,J]=DA(new Map),X=yJ((q)=>{if(typeof Image>"u")return;let D=[...Z.keys()].filter((V)=>!q.has(V));if(D.length>0)J((V)=>{let G=new Map(V);for(let U of D)G.delete(U);return G});for(let V of q){let G=Z.get(V)?.status;if(G==="loaded"||G==="loading")continue;J((U)=>$9(U,V,p4("loading"))),qA(V,M).then((U)=>{J((A)=>{if(!A.has(V))return U?.close(),A;return $9(A,V,U?p4("loaded",U):p4("error"))})})}});WJ(()=>{X($)},[$]);let Y=KA(new Map);WJ(()=>{for(let[q,D]of Y.current)if(!Z.has(q))D.source?.close();Y.current=Z},[Z]);let Q=yJ(async(q)=>{if(!M?.writeFile)return null;try{let D=await M.writeFile(q),V=await createImageBitmap(q).catch(()=>null);return J((G)=>$9(G,D,V?p4("loaded",V):p4("error"))),D}catch{return null}}),K=BJ(()=>Z.size===0?null:{images:Z},[Z]);return BJ(()=>({resources:K,persistImage:Q}),[K,Q])}async function qA($,M){if(/^(https?:|data:|blob:)/i.test($))return VA($);if(!M?.readFile)return null;try{let Z=await M.readFile($);return Z?await createImageBitmap(Z):null}catch{return null}}function VA($){return new Promise((M)=>{let Z=new Image;Z.decoding="async",Z.crossOrigin="anonymous",Z.onload=async()=>{try{M(await createImageBitmap(Z))}catch{M(null)}},Z.onerror=()=>M(null),Z.src=$})}function $9($,M,Z){let J=new Map($);return J.set(M,Z),J}function p4($,M){return{intrinsicHeight:M?.height??0,intrinsicWidth:M?.width??0,source:M??null,status:$}}import{useEffect as wJ,useEffectEvent as _0,useRef as l4,useState as UA}from"react";var GA=48;function bJ({applyNextState:$,autoScrollDuringDrag:M,canvasRef:Z,commentState:J,editorStateRef:X,editorViewportState:Y,focusInput:Q,onActivity:K,readCurrentState:q,resolvePoint:D}){let[V,G]=UA(null),U=l4(null),A=l4(!1),_=l4(null),N=l4(null),z=l4(null),E=q8(V,J.threads),L=V?.kind==="task-toggle"||E?.kind==="link"?"pointer":"text";wJ(()=>{if(V&&V.kind!=="task-toggle"&&!E)G(null)},[V,E]),wJ(()=>()=>{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,!A.current)G(null)},GA)}),S=_0(()=>{if(!A.current)W(),G(null)}),I=_0((w)=>{if(!w){S();return}if(w.kind==="task-toggle"){W(),G((T)=>T?.kind==="task-toggle"&&T.listItemId===w.listItemId?T:w);return}if(w.commentThreadIndex!==null){if(!(J.threads[w.commentThreadIndex]??null)){S();return}W();let k=w.commentThreadIndex;G((m)=>m?.kind!=="task-toggle"&&m?.commentThreadIndex===k?m:w);return}if(w.kind!=="link"){S();return}W(),G((T)=>T?.kind==="link"&&T.title===w.title&&T.url===w.url&&T.startOffset===w.startOffset&&T.endOffset===w.endOffset?T:w)}),y=_0((w)=>{let T=X.current;if(!T)return null;let k=D(w);if(!k)return null;return E6(T,Y.get(),k,J.liveRanges)}),b=_0((w)=>{let T=Z.current;if(T&&_.current===w)T.releasePointerCapture(w)}),H=_0(()=>{_.current=null,N.current=null}),j=_0((w)=>{b(w.pointerId),H()}),B=_0((w)=>{if(z.current=w.pointerType,w.pointerType==="touch")return;let T=Z.current,k=q(),m=D(w);if(!m)return;if(y(w)?.kind==="task-toggle")return;let l=B5(k,Y.get(),m);if(!T||!l)return;if(_.current=w.pointerId,K(),T.setPointerCapture(w.pointerId),w.shiftKey)N.current=k.selection.anchor,$(QM(k,l.regionId,l.offset));else N.current={offset:l.offset,regionId:l.regionId},$(Q0(k,{offset:l.offset,regionId:l.regionId}));Q({offset:l.offset,regionId:l.regionId})}),P=_0((w)=>{let T=N.current,k=q(),m=D(w);if(!m)return;if(_.current!==w.pointerId||!T){I(y(w));return}let a=l2(k,Y.get(),m,T);if(!a)return;K(),M(w),$(Q0(k,{anchor:T,focus:a}))}),F=_0(()=>{if(!A.current)R()}),C=_0((w)=>{let T=z.current==="touch";z.current=null;let k=y(w);if(k?.kind==="task-toggle"){let F0=q(),c0=GM(F0,k.listItemId);if(c0)w.preventDefault(),w.stopPropagation(),K(),$(c0);return}if(k?.kind==="link"&&(w.metaKey||w.ctrlKey)){w.preventDefault(),w.stopPropagation(),w.currentTarget.ownerDocument.defaultView?.open(k.url,"_blank","noopener,noreferrer");return}if(!T){Q();return}let m=q(),a=D(w),l=a?B5(m,Y.get(),a):null;if(l)K(),$(Q0(m,{offset:l.offset,regionId:l.regionId})),Q({offset:l.offset,regionId:l.regionId});else Q()}),u=_0((w)=>{let T=q(),k=D(w),m=y(w);if(!k||m?.kind==="task-toggle")return;let a=H6(T,Y.get(),k);if(!a)return;w.preventDefault(),w.stopPropagation(),K(),$(Q0(T,a)),Q()}),h=_0(()=>{A.current=!0,W()}),g=_0(()=>{A.current=!1,R()});return{canvasHandlers:{onClick:C,onDoubleClick:u,onPointerCancel:j,onPointerDown:B,onPointerLeave:F,onPointerMove:P,onPointerUp:j},cursor:L,leaf:E,leafHandlers:{onPointerEnter:h,onPointerLeave:g}}}import{useEffect as Z9,useEffectEvent as U0,useLayoutEffect as AA,useRef as jJ,useState as NA}from"react";import{useEffect as RR1}from"react";var M9=[{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 TJ($,M=M9){return M.find((Z)=>{let J=Z.shiftKey==="any"?!0:(Z.shiftKey??!1)===($.shiftKey??!1);return Z.key.toLowerCase()===$.key.toLowerCase()&&(Z.altKey??!1)===($.altKey??!1)&&J&&(Z.modKey??!1)===Boolean($.metaKey||$.ctrlKey)})?.command??null}var _A=1024,OJ=16;function RJ({applyNextState:$,editorState:M,editorStateRef:Z,editorViewportState:J,inputRef:X,keybindings:Y,onActivity:Q,onImagePaste:K}){let q=FA(),D=()=>Z.current??M,V=jJ(!1),G=jJ(!1),U=U0((F)=>{if(!F)return;Q(),$(F)}),A=U0(()=>{let F=X.current;if(!F)return;if(typeof document>"u")return;let C=document.execCommand;if(typeof C!=="function")return;try{V.current=!0,C.call(document,"insertText",!1,""),C.call(document,"delete")}catch{}finally{V.current=!1,x4(F,D())}}),_=U0(()=>{if(G.current)return;G.current=!0,A()}),N=U0(()=>{A()}),z=U0((F)=>{if(!q)return;let C=X.current;if(!C)return;let u=J.get(),h=t0(D(),u,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;z(F??D().selection.focus),C.focus({preventScroll:!q}),x4(C,D()),_()}),L=U0((F,C)=>{let h=CJ(C,V8(F)).replace(/\r\n/g,`
|
|
31
|
-
`).split(/(\n)/),g=F;for(let w of h){if(w.length===0)continue;let T=w===`
|
|
32
|
-
`?p5(g):U4(g,w);if(!T)continue;g=T}return g===F?null:g}),W=U0((F,C,u)=>{let h=F.selection.focus,g={regionId:h.regionId,offset:Math.max(0,h.offset-C)},w=Q0(F,{anchor:g,focus:h});return l5(w,u)}),R=U0((F)=>{if(V.current)return;let C=D(),u=EA(F.inputType);if(F.inputType==="insertText"){if(!F.data)return;F.preventDefault();let h=LJ(F.target);if(h>0){U(W(C,h,F.data));return}let g=HA(C,F.data);if(g>0){let w=F.data.slice(g);if(w.length>0)U(L(C,w));return}U(L(C,F.data));return}if(F.inputType==="insertReplacementText"){if(!F.data)return;F.preventDefault();let h=LJ(F.target);U(W(C,h,F.data));return}if(zA(F.inputType)){F.preventDefault(),U(p5(C));return}if(u==="backward"){F.preventDefault(),U(K3(C));return}if(u==="forward"){F.preventDefault(),U(D3(C));return}if(F.inputType==="historyUndo"){F.preventDefault(),U(q3(C)),N();return}if(F.inputType==="historyRedo"){F.preventDefault(),U(V3(C)),N();return}}),S=U0((F)=>{let C=D(),u=F.currentTarget.value,h=V8(C);if(V.current)return;if(CJ(u,h).length===0){x4(F.currentTarget,C);return}U(L(C,u))}),I=U0((F)=>{let C=yA(D(),J.get(),F.nativeEvent,Y);if(!C)return;F.preventDefault(),U(C)}),y=U0((F)=>{let C=Q3(D());if(!C)return;F.preventDefault(),F.clipboardData.setData("text/plain",Q8(C))}),b=U0((F)=>{let C=D(),u=Q3(C);if(!u)return;F.preventDefault(),F.clipboardData.setData("text/plain",Q8(u)),U(x5(C))}),H=U0(async(F)=>{let u=(K?[...F.clipboardData.items].find((w)=>w.kind==="file"&&w.type.startsWith("image/")):void 0)?.getAsFile()??null;if(u&&K){F.preventDefault();let w=await K(u);if(w)U(BM(D(),w));return}let h=F.clipboardData.getData("text/plain");if(h.length===0)return;F.preventDefault();let g=v3(h);U(YM(D(),g,h))}),j=U0(()=>{Q();let F=X.current;if(F)x4(F,D())}),B=U0((F)=>{if(Q(),F.target.matches(":focus-visible"))E()});Z9(()=>{let F=X.current;if(!F)return;x4(F,M)},[M,X]),AA(()=>{z(M.selection.focus)},[M,z]),Z9(()=>{let F=X.current;if(!F)return;let C=(u)=>R(u);return F.addEventListener("beforeinput",C),()=>F.removeEventListener("beforeinput",C)},[X,R]);let P={onCopy:y,onCut:b,onPaste:H,...q?{}:{onKeyDown:I}};return{canvasHandlers:{...P,onFocus:B},focus:E,inputHandlers:{...P,onFocus:j,onInput:S}}}var SJ="";function FA(){let[$,M]=NA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return Z9(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let Z=window.matchMedia("(pointer: coarse)"),J=(X)=>M(X.matches);return Z.addEventListener?.("change",J),()=>Z.removeEventListener?.("change",J)},[]),$}function zA($){return $==="insertLineBreak"||$==="insertParagraph"}function LJ($){let M=$,Z=M?.selectionStart??0,J=M?.selectionEnd??Z;return Math.max(0,J-Z)}function HA($,M){if(M.length<OJ)return 0;let Z=V8($,M.length),J=Math.min(Z.length,M.length);for(let X=J;X>=OJ;X--)if(Z.endsWith(M.slice(0,X)))return X;return 0}function EA($){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 WA($){return $.replaceAll(SJ,"")}function V8($,M=_A){let{anchor:Z,focus:J}=$.selection;if(Z.regionId!==J.regionId||Z.offset!==J.offset)return"";let X=$.documentIndex.regionIndex.get(J.regionId);if(!X)return"";return X.text.slice(Math.max(0,J.offset-M),J.offset)}function CJ($,M){let Z=WA($);return Z.startsWith(M)?Z.slice(M.length):Z}function x4($,M){let Z=V8(M),J=`${SJ}${Z}`;$.value=J,$.setSelectionRange(J.length,J.length)}function yA($,M,Z,J){if(Z.key==="Delete")return D3($);let X=TJ(Z,J);if(X){if(X==="moveToLineStart"||X==="moveToLineEnd")return N3($,M.layout,X==="moveToLineStart"?"Home":"End",Z.shiftKey);if(X==="moveToDocumentStart"||X==="moveToDocumentEnd")return _3($,X==="moveToDocumentStart"?"start":"end",Z.shiftKey);switch(X){case"insertLineBreak":return p5($);case"deleteBackward":return K3($);case"indent":return DM($);case"dedent":return qM($);case"moveListItemUp":return VM($);case"moveListItemDown":return UM($);case"toggleBold":return d5($);case"toggleItalic":return r5($);case"toggleStrikethrough":return c5($);case"toggleUnderline":return a5($);case"toggleCode":return EM($);case"undo":return q3($);case"redo":return V3($);case"selectAll":return KM($)}}if(Z.key==="ArrowLeft"||Z.key==="ArrowRight")return U3($,Z.key==="ArrowLeft"?-1:1,Z.shiftKey);if(Z.key==="ArrowUp"||Z.key==="ArrowDown")return G3($,M.layout,Z.key==="ArrowUp"?-1:1,Z.shiftKey);if(Z.key==="PageUp"||Z.key==="PageDown")return A3($,M.layout,Z.key==="PageUp"?-1:1,Z.shiftKey);if(Z.key.length===1&&!Z.altKey&&!Z.ctrlKey&&!Z.metaKey)return U4($,Z.key);return null}import{useEffectEvent as J9,useLayoutEffect as BA,useMemo as PA,useState as wA}from"react";function kJ({editorState:$,editorStateRef:M,editorViewportState:Z,onViewportScroll:J,scrollContainerRef:X,scheduleOverlayRender:Y,userPresence:Q}){let K=PA(()=>{if(!Q||Q.length===0)return;return w5($.documentIndex,Q)},[$.documentIndex,Q]),[q,D]=wA(void 0),V=J9(()=>{if(K===void 0){if(q!==void 0)D(void 0)}else D(x2(M.current??$,Z.get(),K));Y()}),G=J9((A)=>{if(K===void 0){if(q!==void 0)D(void 0);return}let _=x2(M.current??$,A,K);if(bA(q,_))return;D(_)});BA(()=>{V()},[K]);let U=J9((A)=>{if(!A.viewport||A.viewport.status==="unresolved")return;let _=X.current;if(!_)return;_.scrollTop=A.viewport.scrollTop,J(_)});return{presence:q,scrollToPresence:U,refreshPresence:G}}function bA($,M){if($===M)return!0;if($===void 0||M===void 0||$.length!==M.length)return!1;return $.every((Z,J)=>{let X=M[J];return Z.id===X.id&&TA(Z.viewport,X.viewport)})}function TA($,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 jA,useEffectEvent as h1,useRef as d4}from"react";function mJ({editorStateRef:$,renderContent:M,renderOverlay:Z,renderViewport:J}){let X=d4(null),Y=d4(!1),Q=d4(!1),K=d4(!1),q=d4(!1),D=h1(()=>{if(typeof window>"u"){J();return}Y.current=!0,A()}),V=h1(()=>{if(typeof window>"u"){M(),Z();return}Q.current=!0,A()}),G=h1(()=>{if(typeof window>"u"){M();return}K.current=!0,A()}),U=h1(()=>{if(typeof window>"u"){Z();return}q.current=!0,A()}),A=h1(()=>{if(typeof window>"u"||X.current!==null)return;X.current=window.requestAnimationFrame(()=>{_()})}),_=h1(()=>{X.current=null;let z=Y.current,E=Q.current,L=K.current,W=q.current;if(Y.current=!1,Q.current=!1,K.current=!1,q.current=!1,z){J(),N();return}if(E){M(),Z(),N();return}if(L)M(),N();if(W)Z()}),N=h1(()=>{let z=$.current;if(!z||!I6(z,performance.now()))return;K.current=!0,A()});return jA(()=>{return()=>{if(typeof window>"u"||X.current===null)return;window.cancelAnimationFrame(X.current),X.current=null}},[]),{scheduleContentPaint:G,scheduleFullPaint:V,scheduleFullRender:D,scheduleOverlayPaint:U}}import{useEffectEvent as X9,useLayoutEffect as pJ,useMemo as Y9,useRef as Q9,useState as lJ}from"react";function hJ($){let M=$.documentIndex.regions.find((Y)=>Y.id===$.selection.anchor.regionId),Z=$.documentIndex.regions.find((Y)=>Y.id===$.selection.focus.regionId),J=(M?.start??0)+$.selection.anchor.offset,X=(Z?.start??0)+$.selection.focus.offset;return{end:Math.max(J,X),start:Math.min(J,X)}}function IJ($){let M=OA($);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 fJ=28,vJ=18;function gJ($,M){if(!$)return;let Z=$.getBoundingClientRect();if(M.clientY<Z.top+fJ){$.scrollTop=Math.max(0,$.scrollTop-vJ);return}if(M.clientY>Z.bottom-fJ)$.scrollTop+=vJ}function OA($){let M=uJ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),Z=uJ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return M<=Z?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function uJ($,M,Z){let J=$.findIndex((X)=>X.id===M);if(J===-1)return-1;return J*1e6+Z}function xJ({applyNextState:$,autoScrollDuringDrag:M,canShowSelectionLeaf:Z,editorState:J,editorStateRef:X,editorViewportState:Y,focusInput:Q,onActivity:K,resolvePoint:q,threads:D}){let V=Y9(()=>J0(J),[J]),G=Y9(()=>IJ(J),[J]),U=Y9(()=>C5(J),[J]),[A,_]=lJ(null),[N,z]=lJ(null),E=Q9(null),L=Q9(null),W=Q9(null);pJ(()=>{let H=LA(J,Y.get(),V);_((j)=>mA(j,H)?j:H)},[J,Y,V.end.offset,V.end.regionId,V.start.offset,V.start.regionId]),pJ(()=>{let H=RA({canShowSelectionLeaf:Z,currentLeaf:N,activeMarks:U,handles:A,selectionRange:G,threads:D});z((j)=>kA(j,H)?j:H)},[U,Z,A,N,G,D]);let R=X9((H,j=!0)=>{z((B)=>B?.kind==="create"?{animateInitialComment:j,kind:"thread",left:B.left,threadIndex:H,top:B.top}:B)}),S=X9((H)=>{if(H&&W.current===H.pointerId&&H.currentTarget.hasPointerCapture(H.pointerId))H.currentTarget.releasePointerCapture(H.pointerId);E.current=null,L.current=null,W.current=null}),I=X9((H)=>{let j=X.current,B=L.current,P=q(H);if(!P||!j||!B||W.current!==H.pointerId)return;let F=l2(j,Y.get(),P,B);if(!F)return;H.preventDefault(),H.stopPropagation(),K(),M(H),$(Q0(j,{anchor:B,focus:F}))}),y=(H)=>({onPointerCancel:(j)=>{S(j)},onPointerDown:(j)=>{let B=X.current??J,P=vA(V,H),F=H==="start"?V.start:V.end;if(!A)return;j.preventDefault(),j.stopPropagation(),W.current=j.pointerId,L.current=P,E.current=H,j.currentTarget.setPointerCapture(j.pointerId),K(),Q(),$(Q0(B,{anchor:P,focus:F}))},onPointerMove:(j)=>{if(E.current!==H)return;I(j)},onPointerUp:(j)=>{if(E.current===H)I(j);S(j)}});return{handle:A?{start:{...A.start,props:y("start")},end:{...A.end,props:y("end")}}:null,leaf:N,promoteLeafToThread:R}}function LA($,M,Z){if(Z.collapsed)return null;let J=t0($,M,Z.start),X=t0($,M,Z.end);if(!J||!X)return null;return{end:{left:X.left,top:X.top+X.height},start:{left:J.left,top:J.top}}}function CA($,M,Z){return{activeMarks:Z,kind:"create",left:M.start.left,selection:$,top:M.end.top}}function RA({activeMarks:$,canShowSelectionLeaf:M,currentLeaf:Z,handles:J,selectionRange:X,threads:Y}){if(!M||!X||!J)return null;if(Z?.kind==="thread")return Y[Z.threadIndex]?Z:null;return CA(X,J,$)}function SA($,M){return $?.kind==="create"&&$.left===M.left&&$.selection.regionId===M.selection.regionId&&$.selection.startOffset===M.selection.startOffset&&$.selection.endOffset===M.selection.endOffset&&fA($.activeMarks,M.activeMarks)&&$.top===M.top}function kA($,M){if($===M)return!0;if(!$||!M||$.kind!==M.kind)return!1;if($.kind==="create"&&M.kind==="create")return SA($,M);return $.kind==="thread"&&M.kind==="thread"&&$.animateInitialComment===M.animateInitialComment&&$.left===M.left&&$.threadIndex===M.threadIndex&&$.top===M.top}function mA($,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 fA($,M){return $.length===M.length&&$.every((Z,J)=>Z===M[J])}function vA($,M){return M==="start"?$.end:$.start}import{useEffect as uA,useMemo as cJ,useState as hA}from"react";var r4={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)"},c4={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)"},dJ={...r4,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)"},rJ={...c4,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 aJ($){let M=cJ(()=>gA($),[$]),[Z,J]=hA(M.light),X=cJ(()=>pA(Z),[Z]);return uA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){J(M.light);return}let Y=window.matchMedia("(prefers-color-scheme: dark)"),Q=()=>{J(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:Z,themeStyles:X}}function IA($){return"light"in $&&"dark"in $}function gA($){if(!$)return{dark:c4,light:r4};if(IA($))return $;return{dark:$,light:$}}function pA($){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 dA,useEffectEvent as r0,useRef as K9,useState as U8}from"react";import{useMemo as lA}from"react";function iJ($){return lA(()=>xA({current:null},$),[$])}function xA($,M){return{peek(){return $.current},get(){let Z=$.current;if(Z!==null)return Z;let J=M();return $.current=J,J},invalidate(){$.current=null}}}function sJ($,M){let Z=M.getBoundingClientRect();return{x:$.clientX-Z.left+M.scrollLeft,y:$.clientY-Z.top+M.scrollTop}}function oJ({editorState:$,editorStateRef:M,renderResources:Z,theme:J}){let X=K9(b1()),Y=K9(null),Q=K9({height:240,top:0}),[K,q]=U8(0),[D,V]=U8(240),[G,U]=U8(0),[A,_]=U8(240),N=rA(K),z=r0(()=>{let P=M.current??$,F=Q.current;return z6(P,{height:F.height,paddingX:J.paddingX,paddingY:J.paddingY,top:F.top,width:N},X.current,Z)}),E=iJ(z),L=r0((P)=>{_((F)=>{let C=aA(P,Q.current.height);return F===C?F:C})}),W=r0((P)=>{Q.current={...Q.current,top:P},U((F)=>F===P?F:P),E.invalidate()}),R=r0((P)=>{let F=cA(P),C=F.top!==Q.current.top;if(Q.current=F,U((u)=>u===F.top?u:F.top),C)E.invalidate()}),S=r0((P)=>{let F=Y.current;if(!F)return W(P),P;F.scrollTop=P;let C=F.scrollTop;return W(C),C}),I=r0(()=>{return Y.current?.scrollTop??Q.current.top}),y=r0((P,F)=>{let C=P!==null&&P.documentIndex!==F.documentIndex,u=E.peek();if(!(!C||!u||u.layout.regionLineIndices.has(F.selection.focus.regionId)))E.invalidate()}),b=r0(()=>{return E.invalidate(),E.get()}),H=r0((P)=>{let F=Y.current;return F?sJ(P,F):null}),j=r0((P)=>{gJ(Y.current,P)});return dA(()=>{let P=Y.current;if(!P||typeof ResizeObserver>"u")return;let F=new ResizeObserver((C)=>{let u=C[0];if(!u)return;let h=Math.max(0,Math.floor(u.contentRect.width)),g=nJ(P);Q.current={...Q.current,height:g},q((w)=>w===h?w:h),V((w)=>w===g?w:g)});return F.observe(P),()=>F.disconnect()},[Y]),{actions:{autoScrollDuringDrag:j,getScrollTop:I,observePreparedViewport:L,observeScrollContainer:R,prepareNextPaint:b,reconcileEditorState:y,resolvePoint:H,scrollTo:S},props:{getScrollContainer:(P)=>({onScroll:(F)=>{R(F.currentTarget),P?.onScroll?.(F)},ref:Y}),scrollContent:{style:{height:`${A}px`}}},refs:{scrollContainer:Y},state:{layoutWidth:N,preparedViewport:E,scrollContentHeight:A,surfaceWidth:K,viewportHeight:D,viewportTop:G}}}function rA($){return Math.max(240,Math.floor($||480))}function nJ($){return Math.max(240,$.clientHeight)}function cA($){return{height:nJ($),top:$.scrollTop}}function aA($,M){return Math.max(M,Math.ceil($.totalHeight+24))}function iA(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function D9($,{paintHeight:M,paintTop:Z,width:J}){if(!$)return null;let X=Math.max(240,Math.ceil(M)),Y=iA();$.width=Math.ceil(J*Y),$.height=Math.ceil(X*Y),$.style.width=`${J}px`,$.style.height=`${X}px`,$.style.transform=`translateY(${Z}px)`;let Q=$.getContext("2d");if(!Q)return null;return{context:Q,devicePixelRatio:Y,height:X,width:J}}function q9($,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 tJ($,M){if(!M?.length||!$?.length)return;let Z=new Map($.map((X)=>[X.id,X])),J=[];for(let X of M){let Y=Z.get(X.userId);if(!Y)continue;J.push({...Y,color:X.color,cursor:X.cursor})}return J.length===0?void 0:J}function $X($,M){if(!$)return{didReconcile:!1,state:M};let Z=sA($,M)??XN($,M);return Z?{didReconcile:!0,state:Z}:{didReconcile:!1,state:M}}function sA($,M){let Z=oA($,M);return Z?Q0(M,Z,!1):null}function oA($,M){if(G9($.selection.anchor,$.selection.focus)){let Y=V9($,M,$.selection.focus,"neutral");return Y?{anchor:Y,focus:Y}:null}let Z=ZN($),J=V9($,M,$.selection.anchor,Z.anchor),X=V9($,M,$.selection.focus,Z.focus);return J&&X?{anchor:J,focus:X}:null}function V9($,M,Z,J){let X=$.documentIndex.regionIndex.get(Z.regionId);if(!X)return null;let Y=U9(X,M);if(!Y)return null;return{offset:tA(X.text,Y.text,Z.offset,J),regionId:Y.id}}function U9($,M){let Z=M.documentIndex.regionIndex.get($.id);if(Z)return Z;if($.text.length===0)return null;let J=nA($,M);if(J)return J;return M.documentIndex.regionPathIndex.get($.path)??null}function nA($,M){let Z=null;for(let J of M.documentIndex.regions){if(J.blockType!==$.blockType||J.text!==$.text)continue;if(Z)return null;Z=J}return Z}function tA($,M,Z,J){let X=O0(Z,0,$.length),{prefix:Y,suffix:Q}=f8($,X,X),K=eA(M,Y,Q);if(K!==null)return K;let q=$N(M,Y),D=MN(M,Q);if(J==="before-suffix")return D??q??O0(Z,0,M.length);return q??D??O0(Z,0,M.length)}function eA($,M,Z){let J=o1($,M,Z).filter((X)=>X.startOffset===X.endOffset);return J.length===1?J[0].startOffset:null}function $N($,M){let Z=h0($,M);return Z.length===1?Z[0]+M.length:null}function MN($,M){let Z=h0($,M);return Z.length===1?Z[0]:null}function ZN($){let{anchor:M,focus:Z}=$.selection;if(G9(M,Z))return{anchor:"neutral",focus:"neutral"};return JN($,M,Z)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function JN($,M,Z){let J=$.documentIndex.regionOrderIndex.get(M.regionId),X=$.documentIndex.regionOrderIndex.get(Z.regionId);if(J===void 0||X===void 0)return 0;return J===X?M.offset-Z.offset:J-X}function XN($,M){if(!G9($.selection.anchor,$.selection.focus))return null;let Z=YN($);if(!Z)return null;let J=QN($,M,Z);if(J===null)return null;return KN(M,J)}function YN($){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 QN($,M,Z){let J=eJ($,Z.rootIndex,"before"),X=eJ($,Z.rootIndex,"after"),Y=J?U9(J,M):null,Q=X?U9(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 KN($,M){let Z=P1($.documentIndex.document,M,0,[x({text:""})]),J={...$,documentIndex:K2($.documentIndex,Z,M,0)},X=o2(J.documentIndex,$0(M));return X?Q0(J,X,!1):null}function eJ($,M,Z){let J=Z==="before"?-1:1;for(let X=M+J;X>=0&&X<$.documentIndex.roots.length;X+=J){let Y=DN($,X,Z);if(Y)return Y}return null}function DN($,M,Z){let J=$.documentIndex.roots[M]?.regions??[],X=Z==="before"?J.length-1:0,Y=Z==="before"?-1:1;for(let Q=X;Q>=0&&Q<J.length;Q+=Y){let K=J[Q];if(K&&K.text.length>0)return K}return null}function G9($,M){return $.regionId===M.regionId&&$.offset===M.offset}import{jsx as c,jsxs as A8,Fragment as FN}from"react/jsx-runtime";function N8({blocks:$}){return c(FN,{children:$.map((M)=>qN(M))})}function qN($){switch($.type){case"blockquote":return c("blockquote",{className:"preview-block preview-block-blockquote",children:c(N8,{blocks:$.children})},$.id);case"code":return A8("div",{className:"preview-block preview-block-code",children:[c("div",{className:"preview-rich-header",children:GN($.language,$.meta)}),c("pre",{children:c("code",{children:$.source||" "})})]},$.id);case"heading":{let M=`h${$.depth}`;return c(M,{className:"preview-block preview-block-heading",children:G8($.children)},$.id)}case"list":return $.ordered?c("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((M)=>A9(M))},$.id):c("ul",{className:"preview-block preview-block-list",children:$.items.map((M)=>A9(M))},$.id);case"listItem":return A9($);case"paragraph":return c("p",{className:"preview-block preview-block-paragraph",children:G8($.children)},$.id);case"table":return A8("div",{className:"preview-block preview-block-table",children:[c("div",{className:"preview-rich-header",children:AN($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((M)=>M!==null).length)}),c("div",{className:"preview-table-scroll",children:c("table",{children:c("tbody",{children:$.rows.map((M)=>c("tr",{children:M.cells.map((Z)=>c("td",{children:G8(Z.children)},Z.id))},M.id))})})})]},$.id);case"thematicBreak":return c("hr",{className:"preview-block preview-block-rule"},$.id);case"directive":return c("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id);case"unsupported":return c("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id)}}function A9($){return c("li",{className:"preview-block preview-block-list-item",children:c(N8,{blocks:$.children})},$.id)}function G8($){return $.map((M)=>{switch(M.type){case"break":return c("br",{},M.id);case"image":return A8("span",{className:"preview-inline preview-inline-image",children:[c("img",{alt:M.alt??"",src:M.url,title:M.title??""}),A8("span",{children:[c("strong",{children:NN(M.alt)}),c("small",{children:_N(M.url,M.title)})]})]},M.id);case"inlineCode":return c("code",{className:"preview-inline preview-inline-code",children:M.code},M.id);case"link":return VN(M);case"text":return c("span",{className:"preview-inline",children:UN(M.text,M.marks)},M.id);case"unsupported":return c("span",{className:"preview-inline preview-inline-unsupported",children:M.source},M.id)}})}function VN($){return c("a",{className:"preview-inline preview-inline-link",href:$.url,children:G8($.children)},$.id)}function UN($,M){let Z=$;for(let J of M)switch(J){case"strikethrough":Z=c("del",{children:Z});break;case"italic":Z=c("em",{children:Z});break;case"bold":Z=c("strong",{children:Z});break;case"underline":Z=c("ins",{children:Z});break}return Z}function GN($,M){return[$??"plain text",M].filter(Boolean).join(" • ")}function AN($,M,Z){let J=Z>0?`${Z} aligned ${Z===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${M} ${M===1?"column":"columns"} • ${J}`}function NN($){return $?.trim()?$:"Untitled image"}function _N($,M){return M?.trim()?`${M} • ${$}`:$}var MX=`/* Base Documint host and SSR-fallback styles. */
|
|
19
|
+
`)}var H3=null,dM;function cM(){if(H3===null)H3=new Intl.Segmenter(dM,{granularity:"word"});return H3}var aM=/\p{Script=Arabic}/u,Y6=/\p{M}/u,CY=/\p{Nd}/u;function z3($){return aM.test($)}function $1($){for(let Y of $){let X=Y.codePointAt(0);if(X>=19968&&X<=40959||X>=13312&&X<=19903||X>=131072&&X<=173791||X>=173824&&X<=177983||X>=177984&&X<=178207||X>=178208&&X<=183983||X>=183984&&X<=191471||X>=196608&&X<=201551||X>=63744&&X<=64255||X>=194560&&X<=195103||X>=12288&&X<=12351||X>=12352&&X<=12447||X>=12448&&X<=12543||X>=44032&&X<=55215||X>=65280&&X<=65519)return!0}return!1}var W3=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),z4=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),P3=new Set(["'","’"]),W2=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),rM=new Set([":",".","،","؛"]),sM=new Set(["၏"]),iM=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function oM($){if(y3($))return!0;let Y=!1;for(let X of $){if(W2.has(X)){Y=!0;continue}if(Y&&Y6.test(X))continue;return!1}return Y}function nM($){for(let Y of $)if(!W3.has(Y)&&!W2.has(Y))return!1;return $.length>0}function tM($){if(y3($))return!0;for(let Y of $)if(!z4.has(Y)&&!P3.has(Y)&&!Y6.test(Y))return!1;return $.length>0}function y3($){let Y=!1;for(let X of $){if(X==="\\"||Y6.test(X))continue;if(z4.has(X)||W2.has(X)||P3.has(X)){Y=!0;continue}return!1}return Y}function eM($){let Y=Array.from($),X=Y.length;while(X>0){let Z=Y[X-1];if(Y6.test(Z)){X--;continue}if(z4.has(Z)||P3.has(Z)){X--;continue}break}if(X<=0||X===Y.length)return null;return{head:Y.slice(0,X).join(""),tail:Y.slice(X).join("")}}function $q($,Y){if($.length===0)return!1;for(let X of $)if(X!==Y)return!1;return!0}function Yq($){if(!z3($)||$.length===0)return!1;return rM.has($[$.length-1])}function Xq($){if($.length===0)return!1;return sM.has($[$.length-1])}function Zq($){if($.length<2||$[0]!==" ")return null;let Y=$.slice(1);if(/^\p{M}+$/u.test(Y))return{space:" ",marks:Y};return null}function T3($){for(let Y=$.length-1;Y>=0;Y--){let X=$[Y];if(iM.has(X))return!0;if(!W2.has(X))return!1}return!1}function Jq($,Y){if(Y.preserveOrdinarySpaces||Y.preserveHardBreaks){if($===" ")return"preserved-space";if($==="\t")return"tab";if(Y.preserveHardBreaks&&$===`
|
|
20
|
+
`)return"hard-break"}if($===" ")return"space";if($===" "||$===" "||$===""||$==="\uFEFF")return"glue";if($==="")return"zero-width-break";if($==="")return"soft-hyphen";return"text"}function Y1($){return $.length===1?$[0]:$.join("")}function Kq($,Y,X,Z){let J=[],K=null,Q=[],M=X,D=!1,q=0;for(let U of $){let V=Jq(U,Z),G=V==="text"&&Y;if(K!==null&&V===K&&G===D){Q.push(U),q+=U.length;continue}if(K!==null)J.push({text:Y1(Q),isWordLike:D,kind:K,start:M});K=V,Q=[U],M=X+q,D=G,q+=U.length}if(K!==null)J.push({text:Y1(Q),isWordLike:D,kind:K,start:M});return J}function F3($){return $==="space"||$==="preserved-space"||$==="zero-width-break"||$==="hard-break"}var Qq=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function Mq($,Y){let X=$.texts[Y];if(X.startsWith("www."))return!0;return Qq.test(X)&&Y+1<$.len&&$.kinds[Y+1]==="text"&&$.texts[Y+1]==="//"}function qq($){return $.includes("?")&&($.includes("://")||$.startsWith("www."))}function Dq($){let Y=$.texts.slice(),X=$.isWordLike.slice(),Z=$.kinds.slice(),J=$.starts.slice();for(let Q=0;Q<$.len;Q++){if(Z[Q]!=="text"||!Mq($,Q))continue;let M=[Y[Q]],D=Q+1;while(D<$.len&&!F3(Z[D])){M.push(Y[D]),X[Q]=!0;let q=Y[D].includes("?");if(Z[D]="text",Y[D]="",D++,q)break}Y[Q]=Y1(M)}let K=0;for(let Q=0;Q<Y.length;Q++){let M=Y[Q];if(M.length===0)continue;if(K!==Q)Y[K]=M,X[K]=X[Q],Z[K]=Z[Q],J[K]=J[Q];K++}return Y.length=K,X.length=K,Z.length=K,J.length=K,{len:K,texts:Y,isWordLike:X,kinds:Z,starts:J}}function Uq($){let Y=[],X=[],Z=[],J=[];for(let K=0;K<$.len;K++){let Q=$.texts[K];if(Y.push(Q),X.push($.isWordLike[K]),Z.push($.kinds[K]),J.push($.starts[K]),!qq(Q))continue;let M=K+1;if(M>=$.len||F3($.kinds[M]))continue;let D=[],q=$.starts[M],U=M;while(U<$.len&&!F3($.kinds[U]))D.push($.texts[U]),U++;if(D.length>0)Y.push(Y1(D)),X.push(!0),Z.push("text"),J.push(q),K=U-1}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}var Gq=new Set([":","-","/","×",",",".","+","–","—"]),OY=/^[A-Za-z0-9_]+[,:;]*$/,BY=/[,:;]+$/;function LY($){for(let Y of $)if(CY.test(Y))return!0;return!1}function E3($){if($.length===0)return!1;for(let Y of $){if(CY.test(Y)||Gq.has(Y))continue;return!1}return!0}function Vq($){let Y=[],X=[],Z=[],J=[];for(let K=0;K<$.len;K++){let Q=$.texts[K],M=$.kinds[K];if(M==="text"&&E3(Q)&&LY(Q)){let D=[Q],q=K+1;while(q<$.len&&$.kinds[q]==="text"&&E3($.texts[q]))D.push($.texts[q]),q++;Y.push(Y1(D)),X.push(!0),Z.push("text"),J.push($.starts[K]),K=q-1;continue}Y.push(Q),X.push($.isWordLike[K]),Z.push(M),J.push($.starts[K])}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function Nq($){let Y=[],X=[],Z=[],J=[];for(let K=0;K<$.len;K++){let Q=$.texts[K],M=$.kinds[K],D=$.isWordLike[K];if(M==="text"&&D&&OY.test(Q)){let q=[Q],U=BY.test(Q),V=K+1;while(U&&V<$.len&&$.kinds[V]==="text"&&$.isWordLike[V]&&OY.test($.texts[V])){let G=$.texts[V];q.push(G),U=BY.test(G),V++}Y.push(Y1(q)),X.push(!0),Z.push("text"),J.push($.starts[K]),K=V-1;continue}Y.push(Q),X.push(D),Z.push(M),J.push($.starts[K])}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function Aq($){let Y=[],X=[],Z=[],J=[];for(let K=0;K<$.len;K++){let Q=$.texts[K];if($.kinds[K]==="text"&&Q.includes("-")){let M=Q.split("-"),D=M.length>1;for(let q=0;q<M.length;q++){let U=M[q];if(!D)break;if(U.length===0||!LY(U)||!E3(U))D=!1}if(D){let q=0;for(let U=0;U<M.length;U++){let V=M[U],G=U<M.length-1?`${V}-`:V;Y.push(G),X.push(!0),Z.push("text"),J.push($.starts[K]+q),q+=G.length}continue}}Y.push(Q),X.push($.isWordLike[K]),Z.push($.kinds[K]),J.push($.starts[K])}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function _q($){let Y=[],X=[],Z=[],J=[],K=0;while(K<$.len){let Q=[$.texts[K]],M=$.isWordLike[K],D=$.kinds[K],q=$.starts[K];if(D==="glue"){let U=[Q[0]],V=q;K++;while(K<$.len&&$.kinds[K]==="glue")U.push($.texts[K]),K++;let G=Y1(U);if(K<$.len&&$.kinds[K]==="text")Q[0]=G,Q.push($.texts[K]),M=$.isWordLike[K],D="text",q=V,K++;else{Y.push(G),X.push(!1),Z.push("glue"),J.push(V);continue}}else K++;if(D==="text")while(K<$.len&&$.kinds[K]==="glue"){let U=[];while(K<$.len&&$.kinds[K]==="glue")U.push($.texts[K]),K++;let V=Y1(U);if(K<$.len&&$.kinds[K]==="text"){Q.push(V,$.texts[K]),M=M||$.isWordLike[K],K++;continue}Q.push(V)}Y.push(Y1(Q)),X.push(M),Z.push(D),J.push(q)}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function Hq($){let Y=$.texts.slice(),X=$.isWordLike.slice(),Z=$.kinds.slice(),J=$.starts.slice();for(let K=0;K<Y.length-1;K++){if(Z[K]!=="text"||Z[K+1]!=="text")continue;if(!$1(Y[K])||!$1(Y[K+1]))continue;let Q=eM(Y[K]);if(Q===null)continue;Y[K]=Q.head,Y[K+1]=Q.tail+Y[K+1],J[K+1]=J[K]+Q.head.length}return{len:Y.length,texts:Y,isWordLike:X,kinds:Z,starts:J}}function zq($,Y,X){let Z=cM(),J=0,K=[],Q=[],M=[],D=[];for(let G of Z.segment($))for(let N of Kq(G.segment,G.isWordLike??!1,G.index,X)){let A=N.kind==="text";if(Y.carryCJKAfterClosingQuote&&A&&J>0&&M[J-1]==="text"&&$1(N.text)&&$1(K[J-1])&&T3(K[J-1]))K[J-1]+=N.text,Q[J-1]=Q[J-1]||N.isWordLike;else if(A&&J>0&&M[J-1]==="text"&&nM(N.text)&&$1(K[J-1]))K[J-1]+=N.text,Q[J-1]=Q[J-1]||N.isWordLike;else if(A&&J>0&&M[J-1]==="text"&&Xq(K[J-1]))K[J-1]+=N.text,Q[J-1]=Q[J-1]||N.isWordLike;else if(A&&J>0&&M[J-1]==="text"&&N.isWordLike&&z3(N.text)&&Yq(K[J-1]))K[J-1]+=N.text,Q[J-1]=!0;else if(A&&!N.isWordLike&&J>0&&M[J-1]==="text"&&N.text.length===1&&N.text!=="-"&&N.text!=="—"&&$q(K[J-1],N.text))K[J-1]+=N.text;else if(A&&!N.isWordLike&&J>0&&M[J-1]==="text"&&(oM(N.text)||N.text==="-"&&Q[J-1]))K[J-1]+=N.text;else K[J]=N.text,Q[J]=N.isWordLike,M[J]=N.kind,D[J]=N.start,J++}for(let G=1;G<J;G++)if(M[G]==="text"&&!Q[G]&&y3(K[G])&&M[G-1]==="text")K[G-1]+=K[G],Q[G-1]=Q[G-1]||Q[G],K[G]="";for(let G=J-2;G>=0;G--)if(M[G]==="text"&&!Q[G]&&tM(K[G])){let N=G+1;while(N<J&&K[N]==="")N++;if(N<J&&M[N]==="text")K[N]=K[G]+K[N],D[N]=D[G],K[G]=""}let q=0;for(let G=0;G<J;G++){let N=K[G];if(N.length===0)continue;if(q!==G)K[q]=N,Q[q]=Q[G],M[q]=M[G],D[q]=D[G];q++}K.length=q,Q.length=q,M.length=q,D.length=q;let U=_q({len:q,texts:K,isWordLike:Q,kinds:M,starts:D}),V=Hq(Nq(Aq(Vq(Uq(Dq(U))))));for(let G=0;G<V.len-1;G++){let N=Zq(V.texts[G]);if(N===null)continue;if(V.kinds[G]!=="space"&&V.kinds[G]!=="preserved-space"||V.kinds[G+1]!=="text"||!z3(V.texts[G+1]))continue;V.texts[G]=N.space,V.isWordLike[G]=!1,V.kinds[G]=V.kinds[G]==="preserved-space"?"preserved-space":"space",V.texts[G+1]=N.marks+V.texts[G+1],V.starts[G+1]=V.starts[G]+N.space.length}return V}function Fq($,Y){if($.len===0)return[];if(!Y.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len}];let X=[],Z=0;for(let J=0;J<$.len;J++){if($.kinds[J]!=="hard-break")continue;X.push({startSegmentIndex:Z,endSegmentIndex:J,consumedEndSegmentIndex:J+1}),Z=J+1}if(Z<$.len)X.push({startSegmentIndex:Z,endSegmentIndex:$.len,consumedEndSegmentIndex:$.len});return X}function RY($,Y,X="normal"){let Z=pM(X),J=Z.mode==="pre-wrap"?lM($):xM($);if(J.length===0)return{normalized:J,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let K=zq(J,Y,Z);return{normalized:J,chunks:Fq(K,Z),...K}}var P2=null,bY=new Map,y2=null,Eq=/\p{Emoji_Presentation}/u,Wq=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,j3=null,SY=new Map;function w3(){if(P2!==null)return P2;if(typeof OffscreenCanvas<"u")return P2=new OffscreenCanvas(1,1).getContext("2d"),P2;if(typeof document<"u")return P2=document.createElement("canvas").getContext("2d"),P2;throw Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function Pq($){let Y=bY.get($);if(!Y)Y=new Map,bY.set($,Y);return Y}function N1($,Y){let X=Y.get($);if(X===void 0)X={width:w3().measureText($).width,containsCJK:$1($)},Y.set($,X);return X}function T2(){if(y2!==null)return y2;if(typeof navigator>"u")return y2={lineFitEpsilon:0.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},y2;let $=navigator.userAgent,X=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 y2={lineFitEpsilon:X?0.015625:0.005,carryCJKAfterClosingQuote:Z,preferPrefixWidthsForBreakableRuns:X,preferEarlySoftHyphenBreak:X},y2}function yq($){let Y=$.match(/(\d+(?:\.\d+)?)\s*px/);return Y?parseFloat(Y[1]):16}function O3(){if(j3===null)j3=new Intl.Segmenter(void 0,{granularity:"grapheme"});return j3}function Tq($){return Eq.test($)||$.includes("️")}function vY($){return Wq.test($)}function jq($,Y){let X=SY.get($);if(X!==void 0)return X;let Z=w3();Z.font=$;let J=Z.measureText("\uD83D\uDE00").width;if(X=0,J>Y+0.5&&typeof document<"u"&&document.body!==null){let K=document.createElement("span");K.style.font=$,K.style.display="inline-block",K.style.visibility="hidden",K.style.position="absolute",K.textContent="\uD83D\uDE00",document.body.appendChild(K);let Q=K.getBoundingClientRect().width;if(document.body.removeChild(K),J-Q>0.5)X=J-Q}return SY.set($,X),X}function wq($){let Y=0,X=O3();for(let Z of X.segment($))if(Tq(Z.segment))Y++;return Y}function Oq($,Y){if(Y.emojiCount===void 0)Y.emojiCount=wq($);return Y.emojiCount}function A1($,Y,X){if(X===0)return Y.width;return Y.width-Oq($,Y)*X}function fY($,Y,X,Z){if(Y.graphemeWidths!==void 0)return Y.graphemeWidths;let J=[],K=O3();for(let Q of K.segment($)){let M=N1(Q.segment,X);J.push(A1(Q.segment,M,Z))}return Y.graphemeWidths=J.length>1?J:null,Y.graphemeWidths}function mY($,Y,X,Z){if(Y.graphemePrefixWidths!==void 0)return Y.graphemePrefixWidths;let J=[],K=O3(),Q="";for(let M of K.segment($)){Q+=M.segment;let D=N1(Q,X);J.push(A1(Q,D,Z))}return Y.graphemePrefixWidths=J.length>1?J:null,Y.graphemePrefixWidths}function hY($,Y){let X=w3();X.font=$;let Z=Pq($),J=yq($),K=Y?jq($,J):0;return{cache:Z,fontSize:J,emojiCorrection:K}}function X6($){return $==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen"}function Bq($,Y){while(Y<$.widths.length){let X=$.kinds[Y];if(X!=="space"&&X!=="zero-width-break"&&X!=="soft-hyphen")break;Y++}return Y}function Cq($,Y){if(Y<=0)return 0;let X=$%Y;if(Math.abs(X)<=0.000001)return Y;return Y-X}function kY($,Y,X,Z){if(!Z||Y===null)return $[X];return Y[X]-(X>0?Y[X-1]:0)}function Lq($,Y,X,Z,J,K){let Q=0,M=Y;while(Q<$.length){let D=K?Y+$[Q]:M+$[Q];if((Q+1<$.length?D+J:D)>X+Z)break;M=D,Q++}return{fitCount:Q,fittedWidth:M}}function Rq($,Y,X){let{widths:Z,kinds:J,breakableWidths:K,breakablePrefixWidths:Q}=$;if(Z.length===0)return 0;let M=T2(),D=M.lineFitEpsilon,q=0,U=0,V=!1,G=0,N=0,A=0,_=0,z=-1,F=0;function B(){z=-1,F=0}function W(C=A,T=_,H=U){q++,X?.({startSegmentIndex:G,startGraphemeIndex:N,endSegmentIndex:C,endGraphemeIndex:T,width:H}),U=0,V=!1,B()}function S(C,T){V=!0,G=C,N=0,A=C+1,_=0,U=T}function b(C,T,H){V=!0,G=C,N=T,A=C,_=T+1,U=H}function k(C,T){if(!V){S(C,T);return}U+=T,A=C+1,_=0}function P(C,T){if(!X6(J[C]))return;z=C+1,F=U-T}function y(C){E(C,0)}function E(C,T){let H=K[C],R=Q[C]??null;for(let u=T;u<H.length;u++){let g=kY(H,R,u,M.preferPrefixWidthsForBreakableRuns);if(!V){b(C,u,g);continue}if(U+g>Y+D)W(),b(C,u,g);else U+=g,A=C,_=u+1}if(V&&A===C&&_===H.length)A=C+1,_=0}let w=0;while(w<Z.length){if(!V){if(w=Bq($,w),w>=Z.length)break}let C=Z[w],T=J[w];if(!V){if(C>Y&&K[w]!==null)y(w);else S(w,C);P(w,C),w++;continue}if(U+C>Y+D){if(X6(T)){k(w,C),W(w+1,0,U-C),w++;continue}if(z>=0){if(A>z||A===z&&_>0){W();continue}W(z,0,F);continue}if(C>Y&&K[w]!==null){W(),y(w),w++;continue}W();continue}k(w,C),P(w,C),w++}if(V)W();return q}function uY($,Y,X){if($.simpleLineWalkFastPath)return Rq($,Y,X);let{widths:Z,lineEndFitAdvances:J,lineEndPaintAdvances:K,kinds:Q,breakableWidths:M,breakablePrefixWidths:D,discretionaryHyphenWidth:q,tabStopAdvance:U,chunks:V}=$;if(Z.length===0||V.length===0)return 0;let G=T2(),N=G.lineFitEpsilon,A=0,_=0,z=!1,F=0,B=0,W=0,S=0,b=-1,k=0,P=0,y=null;function E(){b=-1,k=0,P=0,y=null}function w(O=W,v=S,f=_){A++,X?.({startSegmentIndex:F,startGraphemeIndex:B,endSegmentIndex:O,endGraphemeIndex:v,width:f}),_=0,z=!1,E()}function C(O,v){z=!0,F=O,B=0,W=O+1,S=0,_=v}function T(O,v,f){z=!0,F=O,B=v,W=O,S=v+1,_=f}function H(O,v){if(!z){C(O,v);return}_+=v,W=O+1,S=0}function R(O,v){if(!X6(Q[O]))return;let f=Q[O]==="tab"?0:J[O],a=Q[O]==="tab"?v:K[O];b=O+1,k=_-v+f,P=_-v+a,y=Q[O]}function u(O){g(O,0)}function g(O,v){let f=M[O],a=D[O]??null;for(let x=v;x<f.length;x++){let E0=kY(f,a,x,G.preferPrefixWidthsForBreakableRuns);if(!z){T(O,x,E0);continue}if(_+E0>Y+N)w(),T(O,x,E0);else _+=E0,W=O,S=x+1}if(z&&W===O&&S===f.length)W=O+1,S=0}function I(O){if(y!=="soft-hyphen")return!1;let v=M[O];if(v===null)return!1;let f=G.preferPrefixWidthsForBreakableRuns?D[O]??v:v,a=f!==v,{fitCount:x,fittedWidth:E0}=Lq(f,_,Y,N,q,a);if(x===0)return!1;if(_=E0,W=O,S=x,E(),x===v.length)return W=O+1,S=0,!0;return w(O,x,E0+q),g(O,x),!0}function j(O){A++,X?.({startSegmentIndex:O.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:O.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),E()}for(let O=0;O<V.length;O++){let v=V[O];if(v.startSegmentIndex===v.endSegmentIndex){j(v);continue}z=!1,_=0,F=v.startSegmentIndex,B=0,W=v.startSegmentIndex,S=0,E();let f=v.startSegmentIndex;while(f<v.endSegmentIndex){let a=Q[f],x=a==="tab"?Cq(_,U):Z[f];if(a==="soft-hyphen"){if(z)W=f+1,S=0,b=f+1,k=_+q,P=_+q,y=a;f++;continue}if(!z){if(x>Y&&M[f]!==null)u(f);else C(f,x);R(f,x),f++;continue}if(_+x>Y+N){let t0=_+(a==="tab"?0:J[f]),u0=_+(a==="tab"?x:K[f]);if(y==="soft-hyphen"&&G.preferEarlySoftHyphenBreak&&k<=Y+N){w(b,0,P);continue}if(y==="soft-hyphen"&&I(f)){f++;continue}if(X6(a)&&t0<=Y+N){H(f,x),w(f+1,0,u0),f++;continue}if(b>=0&&k<=Y+N){if(W>b||W===b&&S>0){w();continue}let g0=b;w(g0,0,P),f=g0;continue}if(x>Y&&M[f]!==null){w(),u(f),f++;continue}w();continue}H(f,x),R(f,x),f++}if(z){let a=b===v.consumedEndSegmentIndex?P:_;w(v.consumedEndSegmentIndex,0,a)}}return A}var B3=null,gY=new WeakMap;function pY(){if(B3===null)B3=new Intl.Segmenter(void 0,{granularity:"grapheme"});return B3}function bq($){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 Sq($,Y,X){let Z=pY(),J=T2(),{cache:K,emojiCorrection:Q}=hY(Y,vY($.normalized)),M=A1("-",N1("-",K),Q),q=A1(" ",N1(" ",K),Q)*8;if($.len===0)return bq(X);let U=[],V=[],G=[],N=[],A=$.chunks.length<=1,_=X?[]:null,z=[],F=[],B=X?[]:null,W=Array.from({length:$.len}),S=Array.from({length:$.len});function b(y,E,w,C,T,H,R,u){if(T!=="text"&&T!=="space"&&T!=="zero-width-break")A=!1;if(U.push(E),V.push(w),G.push(C),N.push(T),_?.push(H),z.push(R),F.push(u),B!==null)B.push(y)}for(let y=0;y<$.len;y++){W[y]=U.length;let E=$.texts[y],w=$.isWordLike[y],C=$.kinds[y],T=$.starts[y];if(C==="soft-hyphen"){b(E,0,M,M,C,T,null,null),S[y]=U.length;continue}if(C==="hard-break"){b(E,0,0,0,C,T,null,null),S[y]=U.length;continue}if(C==="tab"){b(E,0,0,0,C,T,null,null),S[y]=U.length;continue}let H=N1(E,K);if(C==="text"&&H.containsCJK){let I="",j=0;for(let O of Z.segment(E)){let v=O.segment;if(I.length===0){I=v,j=O.index;continue}if(z4.has(I)||W3.has(v)||W2.has(v)||J.carryCJKAfterClosingQuote&&$1(v)&&T3(I)){I+=v;continue}let f=N1(I,K),a=A1(I,f,Q);b(I,a,a,a,"text",T+j,null,null),I=v,j=O.index}if(I.length>0){let O=N1(I,K),v=A1(I,O,Q);b(I,v,v,v,"text",T+j,null,null)}S[y]=U.length;continue}let R=A1(E,H,Q),u=C==="space"||C==="preserved-space"||C==="zero-width-break"?0:R,g=C==="space"||C==="zero-width-break"?0:R;if(w&&E.length>1){let I=fY(E,H,K,Q),j=J.preferPrefixWidthsForBreakableRuns?mY(E,H,K,Q):null;b(E,R,u,g,C,T,I,j)}else b(E,R,u,g,C,T,null,null);S[y]=U.length}let k=vq($.chunks,W,S),P=_===null?null:wY($.normalized,_);if(B!==null)return{widths:U,lineEndFitAdvances:V,lineEndPaintAdvances:G,kinds:N,simpleLineWalkFastPath:A,segLevels:P,breakableWidths:z,breakablePrefixWidths:F,discretionaryHyphenWidth:M,tabStopAdvance:q,chunks:k,segments:B};return{widths:U,lineEndFitAdvances:V,lineEndPaintAdvances:G,kinds:N,simpleLineWalkFastPath:A,segLevels:P,breakableWidths:z,breakablePrefixWidths:F,discretionaryHyphenWidth:M,tabStopAdvance:q,chunks:k}}function vq($,Y,X){let Z=[];for(let J=0;J<$.length;J++){let K=$[J],Q=K.startSegmentIndex<Y.length?Y[K.startSegmentIndex]:X[X.length-1]??0,M=K.endSegmentIndex<Y.length?Y[K.endSegmentIndex]:X[X.length-1]??0,D=K.consumedEndSegmentIndex<Y.length?Y[K.consumedEndSegmentIndex]:X[X.length-1]??0;Z.push({startSegmentIndex:Q,endSegmentIndex:M,consumedEndSegmentIndex:D})}return Z}function fq($,Y,X,Z){let J=RY($,T2(),Z?.whiteSpace);return Sq(J,Y,X)}function xY($,Y,X){return fq($,Y,!0,X)}function mq($){return $}function IY($,Y,X){let Z=X.get($);if(Z!==void 0)return Z;Z=[];let J=pY();for(let K of J.segment(Y[$]))Z.push(K.segment);return X.set($,Z),Z}function hq($){let Y=gY.get($);if(Y!==void 0)return Y;return Y=new Map,gY.set($,Y),Y}function kq($,Y,X,Z){return Z>0&&$[Z-1]==="soft-hyphen"&&!(Y===Z&&X>0)}function uq($,Y,X,Z,J,K,Q){let M="",D=kq(Y,Z,J,K);for(let q=Z;q<K;q++){if(Y[q]==="soft-hyphen"||Y[q]==="hard-break")continue;if(q===Z&&J>0)M+=IY(q,$,X).slice(J).join("");else M+=$[q]}if(Q>0){if(D)M+="-";M+=IY(K,$,X).slice(Z===K?J:0,Q).join("")}else if(D)M+="-";return M}function gq($,Y,X,Z,J,K,Q){return{text:uq($.segments,$.kinds,Y,Z,J,K,Q),width:X,start:{segmentIndex:Z,graphemeIndex:J},end:{segmentIndex:K,graphemeIndex:Q}}}function Iq($,Y,X){return gq($,Y,X.width,X.startSegmentIndex,X.startGraphemeIndex,X.endSegmentIndex,X.endGraphemeIndex)}function lY($,Y,X){let Z=[];if($.widths.length===0)return{lineCount:0,height:0,lines:Z};let J=hq($),K=uY(mq($),Y,(Q)=>{Z.push(Iq($,J,Q))});return{lineCount:K,height:K*X,lines:Z}}function F4($,Y,X){let Z=$.image?Y.images.get($.image.url)??null:null,J=$.image?.width??null,K=Math.min(X,J??240),Q=Math.max(120,Math.round(K*0.5625));if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return{height:Q,width:K};let M=Math.min(X,J??Z.intrinsicWidth),D=Math.min(1,M/Z.intrinsicWidth);return{height:Math.max(48,Math.round(Z.intrinsicHeight*D)),width:Math.max(48,Math.round(Z.intrinsicWidth*D))}}function dY($,Y){if(!$.image)return`${$.kind}:missing-image`;let X=Y.images.get($.image.url);return`${$.kind}:${$.image.url}:${$.image.width??0}:${X?.status??"loading"}:${X?.intrinsicWidth??0}:${X?.intrinsicHeight??0}`}var cY=[{fontSize:32,lineHeight:36},{fontSize:26,lineHeight:32},{fontSize:21,lineHeight:28},{fontSize:21,lineHeight:28},{fontSize:19,lineHeight:26},{fontSize:18,lineHeight:26}],Z6;function j2($){if($?.type==="heading"){let{fontSize:Y}=iY($.depth);return`700 ${Y}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 _1($,Y){if($?.type==="heading")return iY($.depth).lineHeight;if($?.type==="code")return 22;return Y}function iY($){return cY[$-1]??cY.at(-1)}function w2($,Y,X,Z,J,K,Q){let M=`${K6(Y,Q)}:${J}:${K}:${X}`,D=$.measuredLines.get(M);if(D)return D;let q=xq($,Y,X,Z,J,K,Q);return zY($,M,q)}function J6($,Y,X,Z,J,K,Q,M){let D=`${K6(Y,M)}:${X}:${Z}:${K}:${Q}`,q=$.lineBoundaries.get(D);if(q)return q;let U=nY();if(!U)return rY(J);let V=[{left:0,offset:0}],G=0,N=Y.inlines.filter((A)=>A.end>X&&A.start<Z);if(N.length===0)return rY(J);for(let A of N){let _=Math.max(X,A.start),z=Math.min(Z,A.end),F=Y.text.slice(_,z),B=_-X;if(A.kind==="image"){let W=F4(A,M,Q).width;G+=W,B+=F.length,V.push({left:G,offset:B});continue}U.font=oY(K,A.marks);for(let W of Array.from(F))G+=tY($,U,W),B+=W.length,V.push({left:G,offset:B})}return FY($,D,V)}function pq($,Y,X,Z){let J=`${X}::${Z}::${Y}`,K=$.preparedText.get(J);if(K)return K;let Q=xY(Y,X,{whiteSpace:Z});return HY($,J,Q)}function xq($,Y,X,Z,J,K,Q){let M=Y.text;if(M.length===0)return[{end:0,height:K,start:0,text:"",width:0}];if(rq(Y))return dq($,Y,X,J,K,Q);try{let D=pq($,M,X,tq(Z));return lY(D,J,K).lines.map((U)=>({end:aY(D.segments,U.end),height:K,start:aY(D.segments,U.start),text:U.text,width:U.width}))}catch{return lq(M,J,K)}}function aY($,Y){let X=0;for(let K=0;K<Y.segmentIndex;K+=1)X+=$[K]?.length??0;let Z=$[Y.segmentIndex]??"",J=Array.from(Z);for(let K=0;K<Y.graphemeIndex;K+=1)X+=J[K]?.length??0;return X}function rY($){let Y=[{left:0,offset:0}],X=0,Z=0;for(let J of Array.from($))X+=9,Z+=J.length,Y.push({left:X,offset:Z});return Y}function lq($,Y,X){let Z=Math.max(1,Math.floor(Y/9)),J=eq($,Z),K=0;return J.map((Q)=>{let M=K,D=M+Q.length;return K=D,{end:D,height:X,start:M,text:Q,width:Q.length*9}})}function dq($,Y,X,Z,J,K){let Q=aq($,nY(),Y,X,Z,J,K);if(Q.length===0)return[{end:0,height:J,start:0,text:"",width:0}];return cq(Q,Y.text,Z,J)}function cq($,Y,X,Z){let J=[],K=0;while(K<$.length){let M=$[K].start;if($[K].text===`
|
|
21
|
+
`){J.push({end:M,height:Z,start:M,text:"",width:0}),K+=1;continue}let D=0,q=0,U=K,V=-1,G=Z;while(U<$.length){let A=$[U];if(A.text===`
|
|
22
|
+
`)break;let _=D+A.width;if(_>X&&U>K)break;if(D=_,G=Math.max(G,A.height),A.breakable)V=U,q=D;U+=1}if(U===$.length||$[U]?.text===`
|
|
23
|
+
`){let A=$[U-1]?.end??M;J.push({end:A,height:G,start:M,text:Y.slice(M,A),width:D}),K=U<$.length&&$[U]?.text===`
|
|
24
|
+
`?U+1:U;continue}if(V>=K){let A=$[V].end;J.push({end:A,height:G,start:M,text:Y.slice(M,A),width:q}),K=V+1;continue}let N=$[Math.max(K,U-1)].end;J.push({end:N,height:G,start:M,text:Y.slice(M,N),width:D}),K=Math.max(K+1,U)}let Q=$.at(-1);if(Q?.text===`
|
|
25
|
+
`)J.push({end:Q.end,height:Z,start:Q.end,text:"",width:0});return J}function aq($,Y,X,Z,J,K,Q){let M=[];for(let D of X.inlines){if(D.kind==="image"){let U=F4(D,Q,J);M.push({breakable:!0,end:D.end,height:U.height,start:D.start,text:D.text,width:U.width});continue}if(Y)Y.font=oY(Z,D.marks);let q=D.start;for(let U of Array.from(D.text)){let V=q,G=V+U.length;M.push({breakable:/\s/.test(U),end:G,height:K,start:V,text:U,width:U===`
|
|
26
|
+
`?0:tY($,Y,U)}),q=G}}return M}function rq($){return $.inlines.some((Y)=>Y.kind==="image"||Y.kind==="lineBreak"||nq(Y))}var sY=new WeakMap;function K6($,Y){let X=sY.get($.inlines);if(X&&X.path===$.path&&X.text===$.text)return X.identity;let Z=[$.path,oq($.text),sq($,Y)].join(":");if(!$.inlines.some((J)=>J.kind==="image"))sY.set($.inlines,{identity:Z,path:$.path,text:$.text});return Z}function sq($,Y){return $.inlines.map((X)=>`${X.start}-${X.end}:${iq(X,Y)}`).join("|")}function iq($,Y){if($.kind==="image"&&$.image)return dY($,Y);return`${$.kind}:${$.inlineCode?1:0}:${$.marks.join(",")}:${$.link?.url??""}`}function oq($){let Y=2166136261;for(let X of $)Y^=X.charCodeAt(0),Y=Math.imul(Y,16777619);return(Y>>>0).toString(36)}function nq($){return $.marks.includes("italic")||$.marks.includes("bold")}function oY($,Y){let X=[];if(Y.includes("italic"))X.push("italic");if(Y.includes("bold"))X.push("700");return X.length>0?`${X.join(" ")} ${$}`:$}function nY(){if(Z6!==void 0)return Z6;return Z6=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,Z6}function tY($,Y,X){if(!Y)return 9;let Z=Y.font,J=WY($,Z),K=J.get(X);if(K!==void 0)return K;let Q=Y.measureText(X).width;return J.set(X,Q),Q}function tq($){return $?.type==="code"?"pre-wrap":"normal"}function eq($,Y){if($.length===0)return[""];let X=$.split(`
|
|
27
|
+
`),Z=[];for(let J of X){if(J.length===0){Z.push("");continue}let K=J;while(K.length>Y){let Q=K.slice(0,Y),M=Q.lastIndexOf(" ");if(M<=0){Z.push(Q),K=K.slice(Y);continue}Z.push(Q.slice(0,M)),K=K.slice(M+1)}Z.push(K)}return Z}var E4=10,O2=8,C3=120;function eY($,Y,X,Z,J,K,Q,M,D,q){let U=Math.max(1,...K.rows.map((_)=>_.cells.length)),G=Math.max(C3,D.width-Q-D.paddingX)/U,N=$D(Z),A=M;for(let _=0;_<K.rows.length;_+=1){let z=YD(N.get(_)??[],J,K,G,E4,D.lineHeight,q),F=Math.max(D.lineHeight+O2*2,...z.map((B)=>B.measuredLines.reduce((W,S)=>W+S.height,0)+O2*2));for(let B of z){let W=Q+B.cellIndex*G,S=A+O2;for(let b of B.measuredLines){let k={blockId:B.container.blockId,boundaries:J6(J,B.container,b.start,b.end,b.text,B.font,G-E4*2,q),regionId:B.container.id,end:b.end,font:B.font,height:b.height,left:W+E4,start:b.start,text:b.text,top:S,width:b.width};$.push(k),L3(Y,k),S+=b.height}X.set(B.container.id,{bottom:A+F,left:W,right:W+G,top:A})}XD(Y,K.id,A,A+F),A+=F}return A}function $D($){let Y=new Map;for(let X of $){let Z=X.tableCellPosition;if(!Z)continue;let J=Y.get(Z.rowIndex)??[];J.push({cellIndex:Z.cellIndex,container:X}),Y.set(Z.rowIndex,J)}return Y}function YD($,Y,X,Z,J,K,Q){return[...$].sort((M,D)=>M.cellIndex-D.cellIndex).map(({cellIndex:M,container:D})=>{let q=j2(X),U=_1(X,K),V=w2(Y,D,q,X,Math.max(40,Z-J*2),U,Q);return{cellIndex:M,container:D,font:q,lineHeight:U,measuredLines:V}})}function XD($,Y,X,Z){let J=$.get(Y);$.set(Y,{bottom:J?Math.max(J.bottom,Z):Z,top:J?Math.min(J.top,X):X})}function Q6($){let Y=$.charWidth??e5.charWidth,X=$.lineHeight??e5.lineHeight,Z=Math.max(12,Math.floor($.width/Y)),J=$.text.split(`
|
|
28
|
+
`).reduce((K,Q)=>K+Math.max(1,Math.ceil(Q.length/Z)),0);return{estimatedHeight:J*X,lineCount:J,width:$.width}}function M6($,Y,X=k1(),Z=null){let J=Z??{images:new Map},K={...e5,...Y},Q=[],M=new Map,D=new Map($.regions.map((z)=>[z.id,{textLength:z.text.length}])),q=$.blockIndex,U=W4($.document.blocks),V=new Map,G=new Set($.regions.map((z)=>z.id)),N=K.paddingY,A=null;for(let z of $.blocks){let F=U.get(z.id)??null;if(!F||G1(F))continue;let B=r0(z),W=z.regionIds.filter((P)=>G.has(P));if(!B&&W.length===0)continue;if(A!==null){N+=$6(q,U,A,z.id,K.blockGap);let P=$.blockIndex.get(A);if(P&&!r0(P)){let y=V.get(A);if(y)y.bottom=Math.max(y.bottom,N)}}let S=z.depth,b=K.paddingX+S*K.indentWidth,k=Math.max(40,K.width-b-K.paddingX);if(B)N=ZD(V,z.id,N,K);else if(F.type==="table"){let P=W.map((y)=>$.regionIndex.get(y)).filter((y)=>y!==void 0);N=eY(Q,V,M,P,X,F,b,N,K,J)}else for(let P of W){let y=$.regionIndex.get(P);if(!y)continue;N=JD(Q,V,M,y,X,F,b,N,k,K,J)}A=z.id}let _=[];for(let z of $.blocks){let F=U.get(z.id);if(!F||G1(F))continue;let B=V.get(z.id);if(!B)continue;_.push({bottom:B.bottom,depth:z.depth,id:z.id,top:B.top,type:z.type})}return{blocks:_,regionBounds:M,regionLineIndices:KD(Q),regionMetrics:D,height:Math.max(N,K.paddingY),lines:Q,options:K,width:K.width}}function ZD($,Y,X,Z){let J=Z.lineHeight;return $.set(Y,{top:X,bottom:X+J}),X+J}function JD($,Y,X,Z,J,K,Q,M,D,q,U){let V=j2(K),G=_1(K,q.lineHeight),N=w2(J,Z,V,K,D,G,U),A=M;for(let _ of N){let z={blockId:Z.blockId,boundaries:J6(J,Z,_.start,_.end,_.text,V,D,U),regionId:Z.id,end:_.end,font:V,height:_.height,left:Q,start:_.start,text:_.text,top:A,width:_.width};$.push(z),L3(Y,z),QD(X,z),A+=_.height}return A}function KD($){let Y=[...$].sort((Z,J)=>Z.top-J.top||Z.left-J.left),X=new Map;$.length=0,$.push(...Y);for(let[Z,J]of $.entries()){let K=X.get(J.regionId)??[];K.push(Z),X.set(J.regionId,K)}return X}function QD($,Y){let X=$.get(Y.regionId),Z=Y.left+Y.width,J=Y.top+Y.height;$.set(Y.regionId,X?{bottom:Math.max(X.bottom,J),left:Math.min(X.left,Y.left),right:Math.max(X.right,Z),top:Math.min(X.top,Y.top)}:{bottom:J,left:Y.left,right:Z,top:Y.top})}function L3($,Y){let X=$.get(Y.blockId),Z=Y.top+Y.height;$.set(Y.blockId,{bottom:X?Math.max(X.bottom,Z):Z,top:X?Math.min(X.top,Y.top):Y.top})}function W4($){let Y=new Map,X=(Z)=>{for(let J of Z)if(Y.set(J.id,J),J.type==="blockquote"||J.type==="listItem")X(J.children);else if(J.type==="list")X(J.items)};return X($),Y}var q6=null;function MD($){let Y=/(\d+(?:\.\d+)?)\s*px/.exec($);return Y?Number.parseFloat(Y[1]):16}function H1($){q6??=new Map;let Y=q6.get($);if(Y)return Y;let X=YX(),Z=Math.max(12,Math.round(MD($)));if(!X){let G={ascent:Math.round(Z*0.8),descent:Math.max(2,Z-Math.round(Z*0.8)),emHeight:Z};return q6.set($,G),G}X.font=$;let J=X.measureText("Hg"),K=Math.round(J.actualBoundingBoxAscent||0),Q=Math.round(J.actualBoundingBoxDescent||0),M=K+Q,D=Math.max(Z,M),q=M>0?K:Math.round(D*0.8),U=M>0?Q:Math.max(2,D-q),V={ascent:q,descent:U,emHeight:D};return q6.set($,V),V}function P4($,Y){let{emHeight:X}=H1(Y);return Math.max(0,Math.floor(($-X)/2))}function y4($,Y){let{ascent:X}=H1(Y);return P4($,Y)+X}var D6;function $X($,Y){let X=YX();if(!X||$.length===0)return 0;return X.font=Y,X.measureText($).width}function YX(){if(D6!==void 0)return D6;return D6=(typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null,D6}function R3($,Y){let X=0,Z=$.lines.length-1;while(X<=Z){let J=X+Z>>1,K=$.lines[J];if(Y<K.top){Z=J-1;continue}if(Y>=K.top+K.height){X=J+1;continue}return{index:J,line:K}}return null}function U6($,Y){let X=[...$.regionBounds.entries()].find(([,K])=>{return Y.x>=K.left&&Y.x<=K.right&&Y.y>=K.top&&Y.y<=K.bottom});if(X)return T4($,X[0],Y.y);let Z=R3($,Y.y);if(!Z)return null;let J=qD($,Y.y,Z.index);if(J.length===1)return J[0]??null;return J.find((K)=>{let Q=$.regionBounds.get(K.line.regionId);return Q?Y.x>=Q.left&&Y.x<=Q.right:!1})??[...J].sort((K,Q)=>{let M=$.regionBounds.get(K.line.regionId),D=$.regionBounds.get(Q.line.regionId),q=ZX(Y.x,M),U=ZX(Y.x,D);return q-U})[0]??null}function G6($,Y,X){if($.blocks.length===0)return{endIndex:0,startIndex:0};let Z=Y+X,J=XX($,Y),K=XX($,Z);if(J>0){if($.blocks[J-1].bottom>Y)J-=1}if(K<$.blocks.length){if($.blocks[K].top<Z)K+=1}return{endIndex:K,startIndex:J}}function XX($,Y){let X=0,Z=$.blocks.length;while(X<Z){let J=X+Z>>1;if($.blocks[J].bottom<=Y)X=J+1;else Z=J}return X}function V6($,Y,X){if($.lines.length===0)return{endIndex:0,startIndex:0};let Z=Y+X,J=JX($,Y),K=JX($,Z);if(J>0){let Q=$.lines[J-1];if(Q.top+Q.height>Y)J-=1}if(K<$.lines.length){if($.lines[K].top<Z)K+=1}return{endIndex:K,startIndex:J}}function C0($,Y,X){return B2($,Y,X)?.line??null}function T4($,Y,X){let Z=$.regionLineIndices.get(Y);if(!Z||Z.length===0)return null;let J=Z[0],K=Number.POSITIVE_INFINITY;for(let Q of Z){let M=$.lines[Q],D=X<M.top?M.top-X:X>M.top+M.height?X-(M.top+M.height):0;if(D<K)K=D,J=Q;if(D===0)break}return{index:J,line:$.lines[J]}}function B2($,Y,X){let Z=$.regionLineIndices.get(Y);if(!Z||Z.length===0)return null;let J=0,K=Z.length-1;while(J<=K){let U=J+K>>1,V=Z[U],G=$.lines[V];if(X<G.start){K=U-1;continue}if(X>G.end){J=U+1;continue}return{index:V,line:G}}let Q=Z[0],M=Z[Z.length-1],D=$.lines[Q],q=$.lines[M];if(X<=D.start)return{index:Q,line:D};if(X>=q.end)return{index:M,line:q};return null}function qD($,Y,X){let Z=[];for(let J=X;J>=0;J-=1){let K=$.lines[J];if(Y<K.top||Y>=K.top+K.height)break;Z.unshift({index:J,line:K})}for(let J=X+1;J<$.lines.length;J+=1){let K=$.lines[J];if(Y<K.top||Y>=K.top+K.height)break;Z.push({index:J,line:K})}return Z}function ZX($,Y){if(!Y)return Number.POSITIVE_INFINITY;if($<Y.left)return Y.left-$;if($>Y.right)return $-Y.right;return 0}function G0($,Y){return $.left+DD($.boundaries,Y)}function DD($,Y){for(let Z of $)if(Z.offset===Y)return Z.left;return $.filter((Z)=>Z.offset<=Y).at(-1)?.left??0}function JX($,Y){let X=0,Z=$.lines.length;while(X<Z){let J=X+Z>>1,K=$.lines[J];if(K.top+K.height<=Y)X=J+1;else Z=J}return X}function b3($,Y){if($.length===0)return 0;for(let X=1;X<$.length;X+=1){let Z=$[X-1],J=$[X],K=Z.left+(J.left-Z.left)/2;if(Y<=K)return Z.offset;if(Y<=J.left)return J.offset}return $.at(-1)?.offset??0}var UD=18,GD=14,VD=22;function X1($,Y,X){return G0(Y,X)+T0($,Y)}function T0($,Y){let X=Z1($,Y.blockId,"listItem");if(!X)return 0;return g1($,X.id)?.kind==="task"?VD:UD}function u1($){return{left:$.left,size:GD,top:$.top+3}}function Z1($,Y,X){let Z=$.documentIndex.blockIndex.get(Y)??null;while(Z){if(Z.type===X)return Z;let J=Z.parentBlockId;Z=J?$.documentIndex.blockIndex.get(J)??null:null}return null}function g1($,Y){return $.documentIndex.listItemMarkers.get(Y)??null}function v0($,Y,X){if(!$.regionMetrics.get(X.regionId))return null;let J=C0($,X.regionId,X.offset);if(!J)return null;return{blockId:J.blockId,regionId:J.regionId,height:J.height,left:G0(J,X.offset-J.start),offset:X.offset,top:J.top}}function m0($,Y,X){let Z=C0(Y,X.regionId,X.offset);if(!Z)return X.left;return X.left+T0($,Z)+ND($,Z,X.offset)}function ND($,Y,X){if(X<=Y.end)return 0;let Z=$.documentIndex.regionIndex.get(Y.regionId);if(!Z)return 0;let J=Z.text.slice(Y.end,X);if(!/^[ \t]+$/u.test(J))return 0;return $X(J,Y.font)}function j0($,Y,X){let Z=AD($,Y,X);if(!Z)return null;let J=Z.snapToLineStart?Z.line.left:X.x;return KX($,Y,Z.line,J)}function N6($,Y,X){let Z=$.lines[$.lines.length-1];if(!Z||X.y<=Z.top+Z.height)return null;return KX($,Y,Z,X.x)}function A6($,Y,X,Z){let J=QX(Y,Z.regionId);if(!J)return null;let K=j0($,Y,X);if(K)return{regionId:K.regionId,offset:K.offset};let Q=X.y<_D($);return{regionId:Z.regionId,offset:Q?0:J.text.length}}function _6($,Y,X){let Z=j0($,Y,X);if(!Z)return null;let J=QX(Y,Z.regionId);if(!J||J.text.length===0)return null;let K=Z.offset<J.text.length&&/\w/.test(J.text[Z.offset]??"")?Z.offset:Z.offset>0&&/\w/.test(J.text[Z.offset-1]??"")?Z.offset-1:Z.offset,Q=HD(J.text,K);if(Q.start===Q.end)return null;return{anchor:{regionId:Z.regionId,offset:Q.start},focus:{regionId:Z.regionId,offset:Q.end}}}function KX($,Y,X,Z){let J=$.regionMetrics.get(X.regionId);if(!J)return null;let K=Math.max(0,Z-T0(Y,X)-X.left),Q=b3(X.boundaries,K),M=Math.min(J.textLength,X.start+Q);return{regionId:X.regionId,offset:M,left:G0(X,Q),top:X.top,height:X.height}}function AD($,Y,X){for(let[J,K]of $.regionBounds)if(X.x>=K.left&&X.x<=K.right&&X.y>=K.top&&X.y<=K.bottom){let Q=T4($,J,X.y)?.line??null;return Q?{line:Q}:null}let Z=U6($,X)?.line??null;if(Z)return{line:Z};for(let J of $.blocks){if(X.y<J.top||X.y>J.bottom)continue;for(let Q=$.lines.length-1;Q>=0;Q--)if($.lines[Q].blockId===J.id)return{line:$.lines[Q]};let K=Y.documentIndex.blockIndex.get(J.id);if(K&&r0(K)){let Q=t2(Y.documentIndex,J.id);if(Q){let M=$.lines.find((D)=>D.blockId===Q.id);if(M)return{line:M,snapToLineStart:!0}}}}return null}function QX($,Y){return $.documentIndex.regionIndex.get(Y)??null}function _D($){return $.lines[0]?.top??0}function HD($,Y){let X=Y,Z=Y;while(X>0&&/\w/.test($[X-1]??""))X-=1;while(Z<$.length&&/\w/.test($[Z]??""))Z+=1;return{end:Z,start:X}}function S3($,Y,X){let Z=zD($,X);if(!Z||Z.start!==0)return null;let J=Z1(Y,Z.blockId,"listItem");if(!J)return null;if(g1(Y,J.id)?.kind!=="task")return null;let Q=u1(Z),M=Q.left-4,D=Q.left+Q.size+4,q=Q.top-4,U=Q.top+Q.size+4;return X.x>=M&&X.x<=D&&X.y>=q&&X.y<=U?{listItemId:J.id}:null}function v3($,Y,X){let Z=j0($,Y,X);if(!Z)return null;let J=FD(Y,Z.regionId);if(!J)return null;let K=J.inlines.find((M)=>M.link&&Z.offset>=M.start&&Z.offset<M.end);if(!K?.link)return null;let Q=f3($,Y,Z.regionId,K.start);if(!Q)return null;return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,endOffset:K.end,regionId:Z.regionId,startOffset:K.start,title:K.link.title,url:K.link.url}}function H6($,Y,X,Z){let J=S3($,Y,X);if(J)return{kind:"task-toggle",listItemId:J.listItemId};let K=j0($,Y,X);if(!K)return null;let Q=MX(K.regionId,K.offset,Z),M=Q!==null?qX(Q,$,Y,Z):null,D=v3($,Y,X);if(D)return{anchorBottom:M?.anchorBottom??D.anchorBottom,anchorLeft:M?.anchorLeft??D.anchorLeft,endOffset:D.endOffset,kind:"link",commentThreadIndex:Q,regionId:D.regionId,startOffset:D.startOffset,title:D.title,url:D.url};return{anchorBottom:M?.anchorBottom??K.top+K.height,anchorLeft:M?.anchorLeft??K.left,kind:"text",commentThreadIndex:Q}}function z6($,Y,X,Z){let J=Y.documentIndex.regionIndex.get(X.regionId);if(!J)return null;let K=MX(X.regionId,X.offset,Z),Q=K!==null?qX(K,$,Y,Z):null,M=J.inlines.find((D)=>X.offset>=D.start&&X.offset<=D.end)??null;if(M?.link){let D=f3($,Y,X.regionId,M.start);if(!D)return null;return{anchorBottom:Q?.anchorBottom??D.anchorBottom,anchorLeft:Q?.anchorLeft??D.anchorLeft,commentThreadIndex:K,endOffset:M.end,kind:"link",regionId:X.regionId,startOffset:M.start,title:M.link.title,url:M.link.url}}if(Q)return{anchorBottom:Q.anchorBottom,anchorLeft:Q.anchorLeft,commentThreadIndex:K,kind:"text"};return null}function j4($,Y,X,Z){let J=$.documentIndex.regionIndex.get($.selection.anchor.regionId);if(!Z.image||!J)return null;let K=C0(Y.layout,J.id,Z.start);if(!K)return null;let Q=K.left+T0($,K),M=Q+G0(K,Z.start-K.start)-K.left,D=Q+G0(K,Z.end-K.start)-K.left,{height:q}=F4(Z,X,K.width),U=K.top+Math.max(0,Math.floor((K.height-q)/2));return{left:M,top:U,width:D-M,height:q}}function MX($,Y,X){for(let Z of X)if(Z.regionId===$&&Y>=Z.startOffset&&Y<=Z.endOffset)return Z.threadIndex;return null}function qX($,Y,X,Z){let J=Z.find((K)=>K.threadIndex===$);if(!J)return null;return f3(Y,X,J.regionId,J.startOffset)}function f3($,Y,X,Z){let J=C0($,X,Z);if(!J)return null;return{anchorBottom:J.top+J.height,anchorLeft:G0(J,Z)+T0(Y,J)}}function zD($,Y){return $.lines.find((X)=>Y.y>=X.top-4&&Y.y<=X.top+X.height+4)??$.lines.filter((X)=>Math.abs(Y.y-(X.top+X.height/2))<=10).sort((X,Z)=>Math.abs(Y.y-(X.top+X.height/2))-Math.abs(Y.y-(Z.top+Z.height/2)))[0]??null}function FD($,Y){return $.documentIndex.regionIndex.get(Y)??null}function DX($,Y,X,Z,J,K){let Q=m3(Y,J,K),M=$.measuredContainerHeights.get(Q);if(M!==void 0)return M;let D=J.paddingX??0,q=J.indentWidth??24,U=_1(X,J.lineHeight??24),V=D+Z*q,G=Math.max(40,J.width-V-D);if(Y.inlines.some((_)=>_.kind==="image")){let _=j2(X);return w2($,Y,_,X,G,U,K).reduce((z,F)=>z+F.height,0)}let N=Q6({charWidth:J.charWidth,lineHeight:U,text:Y.text,width:G});return Math.max(U,N.lineCount*U)}function UX($,Y,X,Z){let J=Q6({charWidth:Z,lineHeight:X,text:$.text,width:Y});return Math.max(X,J.lineCount*X)}function m3($,Y,X){return`${K6($,X)}:${Y.width}:${Y.paddingX??0}:${Y.indentWidth??24}:${Y.lineHeight??24}`}function h3($,Y){let X=0,Z=$.entries.length;while(X<Z){let J=X+Z>>1;if($.entries[J].bottom<=Y)X=J+1;else Z=J}return X}function GX($,Y,X,Z,J){let K=Z,Q=J;for(let M=Z;M<J;M+=1){let D=$.regions[M],q=Y.get(D.blockId);if(!q)continue;if(q.type==="table"){let U=X.get(q.regionIds[0]??""),V=X.get(q.regionIds[q.regionIds.length-1]??"");if(U!==void 0)K=Math.min(K,U);if(V!==void 0)Q=Math.max(Q,V+1)}}return{endIndex:Q,startIndex:K}}function VX($,Y,X){return{...$,blocks:$.blocks.map((Z)=>({...Z,bottom:Z.bottom+Y,top:Z.top+Y})),regionBounds:new Map([...$.regionBounds.entries()].map(([Z,J])=>[Z,{bottom:J.bottom+Y,left:J.left,right:J.right,top:J.top+Y}])),height:X,lines:$.lines.map((Z)=>({...Z,top:Z.top+Y}))}}function NX($,Y,X,Z,J){for(let[K,Q]of X.regionBounds){let M=Q.bottom-Q.top,D=Y.regionIndex.get(K);EY($,m3(D??{path:K,inlines:[],text:""},Z,J),M)}}function k3($,Y,X,Z=[],J=k1(),K=null){let Q=K??{images:new Map},M=W4($.document.blocks),D=$.blockIndex,q=new Set(Z),U=Math.max(0,X.top-X.overscan),V=X.top+X.height+X.overscan,G=WD(J,$,M,D,Y,Q),N=h3(G,U),A=h3(G,V);if(N>0){let W=G.entries[N-1];if(W&&W.bottom>U)N-=1}if(A<G.entries.length){let W=G.entries[A];if(W&&W.top<V)A+=1}for(let W of q){let S=G.containerIndices.get(W);if(S===void 0)continue;N=Math.min(N,S),A=Math.max(A,S+1)}if(!Number.isFinite(N)||!Number.isFinite(A))return{estimateRegionBounds:G.estimateRegionBounds,layout:M6({...$,regions:[]},Y,J,Q),totalHeight:G.totalHeight,viewport:X};let _=GX($,D,G.containerIndices,N,A),z=G.entries[_.startIndex]?.top??Y.paddingY??0,F=M6({...$,regions:$.regions.slice(_.startIndex,_.endIndex)},Y,J,Q),B=VX(F,z,G.totalHeight);return NX(J,$,B,Y,Q),{estimateRegionBounds:G.estimateRegionBounds,layout:B,totalHeight:G.totalHeight,viewport:X}}function WD($,Y,X,Z,J,K){let Q=TD(Y,J,K),M=PY($,Y,Q);if(M)return M;let D=J.blockGap??16,q=J.lineHeight??24,U=J.paddingY??0,V=[],G=new Map,N=0,A=null;for(let _ of Y.blocks){let z=X.get(_.id)??null;if(!z||G1(z))continue;let F=r0(_);if(!F&&_.regionIds.length===0)continue;if(A!==null)U+=$6(Z,X,A,_.id,D);if(F)U+=q;else if(z.type==="table"){let B=PD({block:z,containerIndices:G,entries:V,index:N,options:J,runtimeBlocks:Z,totalHeight:U,regions:Y.regions});if(B)N=B.nextIndex,U=B.totalHeight}else for(let B of _.regionIds){let W=Y.regions[N];if(!W){N+=1;continue}let S=DX($,W,z,_.depth,J,K),b=U,k=b+S;V[N]={bottom:k,top:b},G.set(W.id,N),U=k,N+=1}A=_.id}return yY($,Y,Q,{containerIndices:G,entries:V,estimateRegionBounds(_){let z=G.get(_);return z===void 0?null:V[z]??null},totalHeight:U})}function PD({block:$,containerIndices:Y,entries:X,index:Z,options:J,runtimeBlocks:K,totalHeight:Q,regions:M}){let D=K.get($.id),q=D?.regionIds??[];if(q.length===0)return null;let U=M.slice(Z,Z+q.length);if(U.length===0||U[0]?.blockId!==$.id)return null;let V=J.paddingX??0,G=J.indentWidth??24,N=D?.depth??0,A=V+N*G,_=Math.max(C3,J.width-A-V),z=Math.max(1,...$.rows.map((k)=>k.cells.length)),F=_/z,B=Math.max(40,F-E4*2),W=_1($,J.lineHeight??24),S=yD(U,Z),b=Q;for(let k=0;k<$.rows.length;k+=1){let P=S.get(k)??[],y=Math.max(W+O2*2,...P.map(({region:w})=>UX(w,B,W,J.charWidth)+O2*2)),E=b+y;for(let{index:w,region:C}of P)X[w]={bottom:E,top:b},Y.set(C.id,w);b=E}for(let k=Z;k<Z+U.length;k+=1){let P=M[k];if(!P||X[k])continue;X[k]={bottom:b,top:b},Y.set(P.id,k)}return{nextIndex:Z+U.length,totalHeight:b}}function yD($,Y){let X=new Map;for(let[Z,J]of $.entries()){let K=J.tableCellPosition?.rowIndex;if(K===void 0)continue;let Q=X.get(K)??[];Q.push({index:Y+Z,region:J}),X.set(K,Q)}return X}function TD($,Y,X){return[Y.width,Y.paddingX??0,Y.paddingY??0,Y.indentWidth??24,Y.lineHeight??24,Y.blockGap??16,jD($,X)].join(":")}function jD($,Y){if($.imageUrls.size===0)return"";return $.regions.flatMap((X)=>X.inlines.filter((Z)=>Z.kind==="image"&&Z.image).map((Z)=>{let J=Z.image?Y.images.get(Z.image.url):null;return`${Z.image?.url??""}:${Z.image?.width??0}:${J?.status??"loading"}:${J?.intrinsicWidth??0}:${J?.intrinsicHeight??0}`})).join("|")}function u3($,Y,X,Z=null){let J={height:Y.height,overscan:Math.max(160,Y.height),top:Y.top},K=k3($.documentIndex,Y,J,[$.selection.anchor.regionId,$.selection.focus.regionId],X,Z);return{blockMap:W4($.documentIndex.document.blocks),estimateRegionBounds:K.estimateRegionBounds,regionBounds:new Map(K.layout.regionBounds),layout:K.layout,paintHeight:Math.max(240,J.height+J.overscan*2),paintTop:Math.max(0,J.top-J.overscan),totalHeight:K.totalHeight,viewport:{height:J.height,top:J.top}}}function F6($,Y,X){return j0(Y.layout,$,X)??N6(Y.layout,$,X)}function w4($,Y,X,Z){return A6(Y.layout,$,X,Z)}function g3($,Y,X){return _6(Y.layout,$,X)}function I3($,Y,X,Z){return H6(Y.layout,$,X,Z)}function p3($,Y,X,Z){return z6(Y.layout,$,X,Z)}function x3($,Y,X){return v0(Y.layout,$.documentIndex,X)}function J1($,Y,X){let Z=v0(Y.layout,$.documentIndex,X);if(!Z)return null;return{...Z,left:m0($,Y.layout,Z)}}var AX=1;function _X($,Y,X){let Z=$.documentIndex.regionOrderIndex.get($.selection.focus.regionId);if(Z===void 0)return $;let J=$.documentIndex.regions[Z],K=$.selection.focus.offset+Y;if(K>=0&&K<=J.text.length)return y0($,J.id,K,X);if(Y<0){let M=f1($.documentIndex,J.id);if(!M)return $;return y0($,M.id,M.text.length,X)}let Q=n2($.documentIndex,J.id);if(!Q)return $;return y0($,Q.id,0,X)}function HX($,Y,X,Z,J){let K=B2(Y,X.regionId,X.offset);if(!K)return $;let Q=Y.lines[K.index+Z];if(!Q)return $;let M=j0(Y,$,{x:m0($,Y,X)+AX,y:Q.top+Q.height/2});if(!M)return $;return y0($,M.regionId,M.offset,J)}function zX($,Y,X,Z){let J=EX($,Y);if(!J)return $;return y0($,J.regionId,X==="Home"?J.start:J.end,Z)}function FX($,Y,X,Z,J){let K=EX($,Y);if(!K)return $;let M=Math.max(1,Math.floor(480/Y.options.lineHeight)),D=B2(Y,K.regionId,$.selection.focus.offset),q=D?Y.lines[D.index+Z*M]:null;if(!q)return $;let U=j0(Y,$,{x:m0($,Y,X)+AX,y:q.top+q.height/2});if(!U)return $;return y0($,U.regionId,U.offset,J)}function EX($,Y){return C0(Y,$.selection.focus.regionId,$.selection.focus.offset)}var wD=1;function WX($,Y,X,Z,J){let K=$.documentIndex.regionIndex.get($.selection.focus.regionId)??null;if(!K)return null;let Q=$.documentIndex.tableCellIndex.get(K.id)??null,M=$.documentIndex.blockIndex.get(K.blockId)??null;if(!Q||M?.type!=="table")return null;let D=OD($,M.id,Q.rowIndex+Z,Q.cellIndex)??BD($,M.id,Z);if(!D)return $;let q=Y.regionBounds.get(K.id),U=Y.regionBounds.get(D.id);if(!q||!U)return $;let V=U.top+CD(X.top+X.height/2-q.top,0,Math.max(0,U.bottom-U.top-1)),G=j0(Y,$,{x:m0($,Y,X)+wD,y:V});if(!G)return $;return y0($,G.regionId,G.offset,J)}function OD($,Y,X,Z){return V2($.documentIndex,Y,X,Z)}function BD($,Y,X){let Z=$.documentIndex.blockIndex.get(Y),J=$.documentIndex.regions,K=Z?$.documentIndex.roots[Z.rootIndex]?.regionRange:void 0;if(!K)return null;return X<0?J[K.start-1]??null:J[K.end]??null}function CD($,Y,X){return Math.max(Y,Math.min(X,$))}function l3($,Y,X=!1){return _X($,Y,X)}function d3($,Y,X,Z=!1){return LD($,Y,X,Z)}function c3($,Y,X,Z=!1){return RD($,Y,X,Z)}function a3($,Y,X,Z=!1){return zX($,Y,X,Z)}function r3($,Y,X=!1){return bD($,Y,X)}function LD($,Y,X,Z){let J=PX($,Y);if(!J)return $;return WX($,Y,J,X,Z)??HX($,Y,J,X,Z)}function RD($,Y,X,Z){let J=PX($,Y);if(!J)return $;return FX($,Y,J,X,Z)}function bD($,Y,X){let Z=$.documentIndex.regions,J=Y==="start"?Z[0]:Z.at(-1);if(!J)return $;return y0($,J.id,Y==="start"?0:J.text.length,X)}function PX($,Y){return v0(Y,$.documentIndex,{regionId:$.selection.focus.regionId,offset:$.selection.focus.offset})}var SD=80;function TX({context:$,containerBounds:Y,isHeaderRow:X,lineHeight:Z,theme:J}){let K=wX(Y,Z);$.fillStyle=X?J.tableHeaderBackground:J.tableBodyBackground,$.fillRect(K.left,K.top,K.width,K.height),OX($,K,J)}function jX({activeBlockFlashes:$,activeBlockId:Y,activeRegionId:X,context:Z,editorState:J,endIndex:K,layout:Q,regionBounds:M,startIndex:D,theme:q,verticalBleed:U}){if(!Y||!X)return;let V=J.documentIndex.blockIndex.get(Y)??null;if(V?.type!=="table")return;if((J.documentIndex.regionIndex.get(X)??null)?.blockId!==Y)return;let N=M.get(X)??null,A=Q.regionLineIndices.get(X)??null;if(!N||!A||A.length===0)return;let _=Q.lines[A[0]]??null;if(!_)return;let z=wX(N,_.height);if(z.width===0)return;let F=yX({context:Z,endIndex:K,fillStyle:q.activeBlockBackground,layout:Q,left:z.left,lineIndices:A,startIndex:D,verticalBleed:U,width:z.width}),B=V.path?$.get(V.path)??null:null;if(B)yX({context:Z,endIndex:K,fillStyle:f5(q.activeBlockFlash,B),layout:Q,left:z.left,lineIndices:A,startIndex:D,verticalBleed:U,width:z.width});if(!F)return;OX(Z,z,q)}function yX({context:$,endIndex:Y,fillStyle:X,layout:Z,left:J,lineIndices:K,startIndex:Q,verticalBleed:M,width:D}){$.fillStyle=X;let q=!1;for(let U of K){if(U<Q)continue;if(U>=Y)break;let V=Z.lines[U];$.fillRect(J,V.top-M,D,V.height),q=!0}return q}function wX($,Y){return{height:Math.max($.bottom-$.top,Y),left:$.left,top:$.top,width:Math.max($.right-$.left,SD)}}function OX($,Y,X){$.strokeStyle=X.tableBorder,$.strokeRect(Y.left,Y.top,Y.width,Y.height)}var E6=2,vD=3,fD=12,mD=6,hD=3,kD=8,uD=12,gD=28,ID=4,BX=1,pD=5,xD=2,lD=1;function CX($,Y,X,Z,J,K,Q){if(!Z||Y.start!==0)return;if(X?.type==="code"){let M=Math.max(0,Y.left-uD);$.fillStyle=K.codeBackground,$.fillRect(M,Z.top-ID,Math.max(Z.right-Y.left+gD,Q-M),Z.bottom-Z.top+kD);return}if(X?.type!=="table")return;TX({context:$,containerBounds:Z,isHeaderRow:J?.rowIndex===0,lineHeight:Y.height,theme:K})}function LX($,Y,X,Z,J,K,Q,M){if(Y.blockId!==J||X?.type==="table")return;let D=Z?K.get(Z)??null:null;if($.fillStyle=Q.activeBlockBackground,$.fillRect(0,Y.top-E6,M,Y.height),!D)return;$.fillStyle=f5(Q.activeBlockFlash,D),$.fillRect(0,Y.top-E6,M,Y.height)}function RX($,Y,X,Z,J,K){let Q=new Map;for(let M=Z;M<J;M+=1){let D=$.lines[M],q=X.get(D.blockId);if(q?.type!=="heading"||q.depth!==1&&q.depth!==2)continue;let U=Q.get(q.id),V={bottom:D.top+D.height,left:D.left+T0(Y,D),right:K-$.options.paddingX};Q.set(q.id,U?{bottom:Math.max(U.bottom,V.bottom),left:U.left,right:U.right}:V)}return Q}function bX($,Y,X,Z,J,K){for(let Q=X;Q<Z;Q+=1){let M=Y.blocks[Q];if(M.type==="divider"){let D=Y.options.paddingX+M.depth*Y.options.indentWidth,q=K-Y.options.paddingX,U=Math.round(M.top+(M.bottom-M.top-BX)/2);vX($,{color:J.dividerRule??J.headingRule,left:D,right:q,thickness:BX,top:U})}}}function SX($,Y,X){for(let Z of Y.values())vX($,{color:X.headingRule,left:Z.left,minimumWidth:xD,right:Z.right,thickness:lD,top:Z.bottom+pD})}function vX($,Y){$.fillStyle=Y.color,$.fillRect(Y.left,Y.top,Math.max(Y.minimumWidth??0,Y.right-Y.left),Y.thickness)}function fX($,Y,X,Z,J){let K=new Map;for(let Q=Z;Q<J;Q+=1){let M=$.lines[Q],D=Z1(Y,M.blockId,"blockquote");if(!D)continue;let q=K.get(D.id),U={bottom:M.top+M.height,isActive:M.blockId===X,left:$.options.paddingX+(D.depth+1)*$.options.indentWidth-10,top:M.top};K.set(D.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 K}function mX($,Y,X){for(let Z of Y.values())$.fillStyle=Z.isActive?X.blockquoteRuleActive:X.blockquoteRule,$.fillRect(Z.left,Z.top+vD,hD,Math.max(fD,Z.bottom-Z.top-mD))}var dD=1,cD=2,aD=2;function s3({context:$,devicePixelRatio:Y,editorState:X,height:Z,layout:J,normalizedSelection:K,presence:Q,showCaret:M,theme:D,viewportTop:q,width:U}){$.save(),$.scale(Y,Y),$.clearRect(0,0,U,Z);let V=K.start.regionId===K.end.regionId&&K.start.offset!==K.end.offset,G=M&&!V;if($.translate(0,-q),G)hX($,X,J,{color:D.caret,offset:X.selection.focus.offset,regionId:X.selection.focus.regionId});if(Q)for(let N of Q){if(!N.cursorPoint)continue;hX($,X,J,{color:N.color??D.leafAccent,offset:N.cursorPoint.offset,regionId:N.cursorPoint.regionId})}$.restore()}function hX($,Y,X,Z){let J=v0(X,Y.documentIndex,{regionId:Z.regionId,offset:Z.offset});if(!J)return;let K=m0(Y,X,J),Q=rD(X,J);$.fillStyle=Z.color,$.fillRect(K,Q.top,cD,Q.height)}function rD($,Y){let X=C0($,Y.regionId,Y.offset),Z=X?.font??'16px "Iowan Old Style", "Palatino Linotype", serif',{ascent:J,descent:K}=H1(Z),Q=Math.max(1,J+K),M=Math.min(Y.height-aD,Q),D=X?Math.max(X.top,X.top+P4(X.height,Z)-dD):Y.top+Math.max(0,Math.floor((Y.height-M)/2));return{height:M,top:D}}var kX=2,uX=8,sD=3,iD=1.5,oD=2,C2={elbow:{x:6.5,y:10.5},end:{x:11.5,y:3.5},start:{x:3.5,y:7.5}};function gX($,Y,X,Z,J,K,Q=null){if(!X||Y.start!==0)return;if(Q){let M=m7(Q),D=YU(X,Y,Z,J,$);$.save(),$.translate(D.x,D.y),$.scale(M,M),$.translate(-D.x,-D.y)}if(X.kind==="task")nD($,Y,X.checked,K,Q);else if($.fillStyle=Q?X4(K.listMarkerText,Q,K):K.listMarkerText,X.kind==="ordered")$U($,X.label,Z,J);else $.fillText(X.label,Y.left-kX,J);if(Q)$.restore()}function nD($,Y,X,Z,J=null){let K=u1(Y);if(tD($,K,X,Z,J),!X)return;eD($,K,Z,J)}function tD($,Y,X,Z,J=null){let K=X?Z.checkboxCheckedFill:Z.checkboxUncheckedFill,Q=X?Z.checkboxCheckedStroke:Z.checkboxUncheckedStroke;$.fillStyle=J?X4(K,J,Z):K,$.strokeStyle=J?X4(Q,J,Z):Q,$.beginPath(),$.lineWidth=iD,$.roundRect(Y.left,Y.top,Y.size,Y.size,sD),$.fill(),$.stroke()}function eD($,Y,X,Z=null){$.strokeStyle=Z?X4(X.checkboxCheckmark,Z,X):X.checkboxCheckmark,$.lineWidth=oD,$.beginPath(),$.moveTo(Y.left+C2.start.x,Y.top+C2.start.y),$.lineTo(Y.left+C2.elbow.x,Y.top+C2.elbow.y),$.lineTo(Y.left+C2.end.x,Y.top+C2.end.y),$.stroke()}function $U($,Y,X,Z){let J=$.textAlign;$.textAlign="right",$.fillText(Y,X-uX,Z),$.textAlign=J}function YU($,Y,X,Z,J){if($.kind==="task"){let M=u1(Y);return{x:M.left+M.size/2,y:M.top+M.size/2}}let K=J.measureText($.label),Q=Z-(K.actualBoundingBoxAscent-K.actualBoundingBoxDescent)/2;if($.kind==="ordered")return{x:X-uX-K.width/2,y:Q};return{x:Y.left-kX+K.width/2,y:Q}}var XU=2,ZU=1,JU=2,KU=5,QU=2,MU=3;function IX($,Y){let X=$.documentIndex.regionOrderIndex,Z=X.get(Y.start.regionId),J=X.get(Y.end.regionId);return Z===void 0||J===void 0?null:{end:J,start:Z}}function pX($,Y,X,Z,J,K){if(!J)return;let Q=Y.documentIndex.regionOrderIndex.get(X.regionId);if(Q===void 0||Q<J.start||Q>J.end)return;let M=Q===J.start?Math.max(X.start,Z.start.offset):X.start,D=Q===J.end?Math.min(X.end,Z.end.offset):X.end;if(D<=M)return;$.fillStyle=K.selectionBackground,$.fillRect(X1(Y,X,M-X.start),X.top+ZU,Math.max(XU,X1(Y,X,D-X.start)-X1(Y,X,M-X.start)),X.height-JU)}function xX($,Y,X,Z,J,K){for(let Q of Z){if(Q.regionId!==X.regionId)continue;let M=Math.max(Q.startOffset,X.start),D=Math.min(Q.endOffset,X.end);if(D<=M)continue;$.fillStyle=qU(Q,J,K),$.fillRect(X1(Y,X,M-X.start),X.top+X.height-KU,Math.max(QU,X1(Y,X,D-X.start)-X1(Y,X,M-X.start)),MU)}}function qU($,Y,X){if($.resolved)return $.threadIndex===Y?X.commentHighlightResolvedActive:X.commentHighlightResolved;return $.threadIndex===Y?X.commentHighlightActive:X.commentHighlight}function dX($,Y,X,Z,J,K,Q){let M=X.image?Z.images.get(X.image.url):null,D=GU(X,Z,Q),q=VU(Y,K,Q,D);if($.fillStyle=J.imageSurfaceBackground,$.fillRect(q.left,q.top,q.width,q.height),M?.status==="loaded"&&M.source)$.drawImage(M.source,q.left,q.top,q.width,q.height);else DU($,J,{...q,status:M?.status==="error"?"error":"loading"});$.strokeStyle=J.imageSurfaceBorder,$.strokeRect(q.left,q.top,q.width,q.height)}function DU($,Y,X){let Z=X.status==="loading"?"Loading image":"Image unavailable",J=NU(X),K=X.top+X.height/2+J.size*0.9;if($.save(),$.beginPath(),$.rect(X.left,X.top,X.width,X.height),$.clip(),X.status==="loading")UU($,Y,X);$.strokeStyle=Y.imagePlaceholderIcon,$.lineWidth=1.5,$.strokeRect(J.left,J.top,J.size,J.size),$.beginPath(),$.arc(J.left+J.size*0.28,J.top+J.size*0.3,J.size*0.1,0,Math.PI*2),$.moveTo(J.left+J.size*0.12,J.top+J.size*0.82),$.lineTo(J.left+J.size*0.42,J.top+J.size*0.5),$.lineTo(J.left+J.size*0.58,J.top+J.size*0.66),$.lineTo(J.left+J.size*0.78,J.top+J.size*0.38),$.lineTo(J.left+J.size*0.88,J.top+J.size*0.82),$.stroke(),$.font='500 12px "Iowan Old Style", "Palatino Linotype", serif',$.fillStyle=Y.imagePlaceholderText,$.textAlign="center",$.textBaseline="middle",$.fillText(Z,X.left+X.width/2,K),$.restore()}function UU($,Y,X){let Z=Math.max(48,Math.round(X.width*0.22)),J=X.width+Z*2,K=performance.now()%1800/1800,Q=X.left-Z+J*K,M=$.createLinearGradient(Q,X.top,Q+Z,X.top);M.addColorStop(0,"rgba(255,255,255,0)"),M.addColorStop(0.5,Y.imageLoadingOverlay),M.addColorStop(1,"rgba(255,255,255,0)"),$.fillStyle=M,$.fillRect(X.left,X.top,X.width,X.height)}function GU($,Y,X){if(!$.image)return lX(X);let Z=Y.images.get($.image.url);if(!Z||Z.intrinsicWidth<=0||Z.intrinsicHeight<=0)return lX(X);return Math.max(48,Math.round(X*(Z.intrinsicHeight/Z.intrinsicWidth)))}function VU($,Y,X,Z){return{height:Z,left:Y,top:$.top+Math.max(0,Math.floor(($.height-Z)/2)),width:X}}function NU($){let Y=Math.max(18,Math.min(34,Math.round(Math.min($.width,$.height)*0.18)));return{left:$.left+Math.max(12,Math.round(($.width-Y)/2)),size:Y,top:$.top+Math.max(12,Math.round($.height/2-Y*0.95))}}function lX($){return Math.max(48,Math.round($*0.5625))}var AU=6,cX=3,_U=12,HU=10,zU=2,aX=4,FU=4,EU=1.5,rX=2,sX=1.25;function oX($,Y,X,Z,J,K,Q,M,D){if(!X){$.fillStyle=Q,$.fillText(Y.text,Z,J);return}let q=X.inlines.filter((U)=>U.end>Y.start&&U.start<Y.end);if(q.length===0){$.fillStyle=Q,$.fillText(Y.text,Z,J);return}for(let U of q){let V=Math.max(Y.start,U.start),G=Math.min(Y.end,U.end);if(X.text.slice(V,G).length===0)continue;let{left:A,right:_}=i3(Y,Z,V,G),z=TU(Y.font,U.marks);if($.font=z,U.kind==="image"){let F=Math.max(24,_-A);dX($,Y,U,M,D,A,F);continue}if(U.kind==="code"){WU($,Y,z,D,A,_),iX($,Y,X.text,Z,J,V,G,D.inlineCodeText,K,D,{strikethrough:!1,underline:!1});continue}iX($,Y,X.text,Z,J,V,G,U.link?D.linkText:Q,K,D,{strikethrough:U.marks.includes("strikethrough"),underline:U.marks.includes("underline")||Boolean(U.link)})}}function iX($,Y,X,Z,J,K,Q,M,D,q,U){let V=R7(K,Q,D);for(let G=0;G<V.length-1;G+=1){let N=V[G],A=V[G+1];if(A<=N)continue;let _=X.slice(N,A);if(_.length===0)continue;let{left:z,right:F}=i3(Y,Z,N,A),B=b7(D,N,A),W=S7(M,B,q);if($.fillStyle=W,$.fillText(_,z,J),U.strikethrough)$.fillRect(z,PU(J,Y.height,$.font),Math.max(rX,F-z),sX);if(U.underline)$.fillRect(z,yU(J,Y.height,$.font),Math.max(rX,F-z),sX)}}function nX($,Y,X,Z,J,K,Q){if(!X||K.length===0)return;for(let M of K){if(M.startOffset<Y.start||M.startOffset>Y.end)continue;let D=Z+(G0(Y,M.startOffset-Y.start)-Y.left);$.fillStyle=v7(Q,M),$.fillText(M.text,D,J)}}function tX($,Y,X,Z,J,K,Q){if(!X||K.length===0)return;for(let M of K){if(M.offset<Y.start||M.offset>=Y.end)continue;let{left:D,right:q}=i3(Y,Z,M.offset,M.offset+1),U=Math.max(aX,(q-D)/2+aX+FU*M.progress),{ascent:V,descent:G}=H1(Y.font),N=J-Math.max(1,V*0.42)+Math.max(0.5,G*0.15);$.strokeStyle=f7(M,Q),$.lineWidth=EU,$.beginPath(),$.arc((D+q)/2,N,U,0,Math.PI*2),$.stroke()}}function WU($,Y,X,Z,J,K){let Q=P4(Y.height,X),M=Y.top+Q+zU,D=Math.max(_U,Y.height-Q-AU);$.fillStyle=Z.inlineCodeBackground,$.fillRect(J-cX,M,Math.max(HU,K-J+cX*2),D)}function PU($,Y,X){let{ascent:Z}=H1(X),J=$-y4(Y,X);return Math.max(J+2,$-Math.round(Z*0.32))}function yU($,Y,X){let{descent:Z}=H1(X),J=Math.max(1,Math.round(Math.max(2,Z)*0.35)),K=$+Z-J,Q=$-y4(Y,X);return Math.min(Q+Y-4,K)}function TU($,Y){let X=[];if(Y.includes("italic"))X.push("italic");if(Y.includes("bold"))X.push("700");return X.length>0?`${X.join(" ")} ${$}`:$}function i3($,Y,X,Z){return{left:Y+(G0($,X-$.start)-$.left),right:Y+(G0($,Z-$.start)-$.left)}}function o3($,Y,X,Z){jU({activeBlockId:Z.activeBlockId,activeRegionId:Z.activeRegionId,activeThreadIndex:Z.activeThreadIndex,containerLineBounds:Y.regionBounds,context:X,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:Y.layout,liveCommentRanges:Z.liveCommentRanges,normalizedSelection:Z.normalizedSelection,now:Z.now,resources:Z.resources??{images:new Map},runtimeBlockMap:Y.blockMap,theme:Z.theme,viewportTop:Y.paintTop,width:Z.width})}function n3($,Y,X,Z){s3({context:X,devicePixelRatio:Z.devicePixelRatio,editorState:$,height:Z.height,layout:Y.layout,normalizedSelection:Z.normalizedSelection,presence:Z.presence,showCaret:Z.showCaret,theme:Z.theme,viewportTop:Y.paintTop,width:Z.width})}function jU({activeBlockId:$,activeRegionId:Y,activeThreadIndex:X,containerLineBounds:Z,context:J,devicePixelRatio:K,editorState:Q,height:M,layout:D,liveCommentRanges:q,normalizedSelection:U,now:V=CU(),resources:G,runtimeBlockMap:N,theme:A,viewportTop:_,width:z}){J.save(),J.scale(K,K),J.clearRect(0,0,z,M),J.fillStyle=A.background,J.fillRect(0,0,z,M),J.textBaseline="alphabetic",J.translate(0,-_);let{endIndex:F,startIndex:B}=V6(D,_,M),W=IX(Q,U),S=O7(Q,V),b=B7(Q,V),k=w7(Q,V),P=L7(Q,V),y=C7(Q,V),E=fX(D,Q,$,B,F),w=RX(D,Q,N,B,F,z);for(let T=B;T<F;T+=1){let H=D.lines[T];CX(J,H,N.get(H.blockId)??null,Z.get(H.regionId)??null,Q.documentIndex.tableCellIndex.get(H.regionId)??null,A,z)}let C=G6(D,_,M);bX(J,D,C.startIndex,C.endIndex,A,z),jX({activeBlockFlashes:S,activeBlockId:$,activeRegionId:Y,context:J,editorState:Q,endIndex:F,layout:D,regionBounds:Z,startIndex:B,theme:A,verticalBleed:E6});for(let T=B;T<F;T+=1){let H=D.lines[T];wU({activeBlockId:$,activeBlockFlashes:S,activeDeletedTextFades:b,activeInsertedTextHighlights:k,activeListMarkerPops:P,activePunctuationPulses:y,activeThreadIndex:X,context:J,editorState:Q,line:H,liveCommentRanges:q,normalizedSelection:U,resources:G,runtimeBlockMap:N,selectionRegionOrderRange:W,theme:A,width:z})}SX(J,w,A),mX(J,E,A),J.restore()}function wU({activeBlockId:$,activeBlockFlashes:Y,activeDeletedTextFades:X,activeInsertedTextHighlights:Z,activeListMarkerPops:J,activePunctuationPulses:K,activeThreadIndex:Q,context:M,editorState:D,line:q,liveCommentRanges:U,normalizedSelection:V,resources:G,runtimeBlockMap:N,selectionRegionOrderRange:A,theme:_,width:z}){let F=N.get(q.blockId)??null,B=D.documentIndex.blockIndex.get(q.blockId)?.path??null,W=D.documentIndex.regionIndex.get(q.regionId)??null,S=W?.path??"",b=Z1(D,q.blockId,"listItem"),k=b?g1(D,b.id):null,P=b?J.get(b.path)??null:null,y=q.left+T0(D,q),E=OU(q),w=F?.type==="code"?_.codeText:BU(F,_);M.font=q.font,LX(M,q,F,B,$,Y,_,z),pX(M,D,q,V,A,_),xX(M,D,q,U,Q,_),gX(M,q,k,y,E,_,P),oX(M,q,W,y,E,Z.get(S)??[],w,G,_),nX(M,q,W,y,E,X.get(S)??[],w),tX(M,q,W,y,E,K.get(S)??[],_)}function OU($){return $.top+y4($.height,$.font)}function BU($,Y){switch($?.type){case"heading":return Y.headingText;case"blockquote":return Y.blockquoteText;case"table":return Y.headingText;default:return Y.paragraphText}}function CU(){return typeof performance<"u"?performance.now():Date.now()}import{forwardRef as vU,createElement as fU}from"react";var W6=(...$)=>$.filter((Y,X,Z)=>{return Boolean(Y)&&Y.trim()!==""&&Z.indexOf(Y)===X}).join(" ").trim();var eX=($)=>$.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var $Z=($)=>$.replace(/^([A-Z])|[\s-_]+(\w)/g,(Y,X,Z)=>Z?Z.toUpperCase():X.toLowerCase());var t3=($)=>{let Y=$Z($);return Y.charAt(0).toUpperCase()+Y.slice(1)};import{forwardRef as SU,createElement as ZZ}from"react";var P6={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 YZ=($)=>{for(let Y in $)if(Y.startsWith("aria-")||Y==="role"||Y==="title")return!0;return!1};import{createContext as LU,useContext as RU,useMemo as uW,createElement as gW}from"react";var bU=LU({});var XZ=()=>RU(bU);var JZ=SU(({color:$,size:Y,strokeWidth:X,absoluteStrokeWidth:Z,className:J="",children:K,iconNode:Q,...M},D)=>{let{size:q=24,strokeWidth:U=2,absoluteStrokeWidth:V=!1,color:G="currentColor",className:N=""}=XZ()??{},A=Z??V?Number(X??U)*24/Number(Y??q):X??U;return ZZ("svg",{ref:D,...P6,width:Y??q??P6.width,height:Y??q??P6.height,stroke:$??G,strokeWidth:A,className:W6("lucide",N,J),...!K&&!YZ(M)&&{"aria-hidden":"true"},...M},[...Q.map(([_,z])=>ZZ(_,z)),...Array.isArray(K)?K:[K]])});var m=($,Y)=>{let X=vU(({className:Z,...J},K)=>fU(JZ,{ref:K,iconNode:Y,className:W6(`lucide-${eX(t3($))}`,`lucide-${$}`,Z),...J}));return X.displayName=t3($),X};var mU=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],z1=m("columns-2",mU);var hU=[["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"}]],F1=m("rows-3",hU);var kU=[["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"}]],E1=m("send-horizontal",kU);var uU=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],O4=m("arrow-down",uU);var gU=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],B4=m("arrow-up",gU);var IU=[["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"}]],C4=m("bold",IU);var pU=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],I1=m("check",pU);var xU=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],L4=m("chevron-down",xU);var lU=[["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"}]],R4=m("heading-1",lU);var dU=[["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"}]],b4=m("heading-2",dU);var cU=[["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"}]],S4=m("heading-3",cU);var aU=[["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"}]],v4=m("heading-4",aU);var rU=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],f4=m("heading-5",rU);var sU=[["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"}]],m4=m("heading-6",sU);var iU=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],h4=m("heading",iU);var oU=[["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"}]],k4=m("italic",oU);var nU=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],u4=m("list-ordered",nU);var tU=[["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"}]],g4=m("list-todo",tU);var eU=[["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"}]],I4=m("list",eU);var $G=[["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"}]],p4=m("message-square-plus",$G);var YG=[["path",{d:"M5 12h14",key:"1ays0h"}]],x4=m("minus",YG);var XG=[["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"}]],p1=m("pencil",XG);var ZG=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],L2=m("plus",ZG);var JG=[["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"}]],l4=m("strikethrough",JG);var KG=[["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"}]],W1=m("table-2",KG);var QG=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],d4=m("text-quote",QG);var MG=[["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"}]],L0=m("trash-2",MG);var qG=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],c4=m("underline",qG);var DG=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],a4=m("x",DG);import{jsx as R2,jsxs as NG}from"react/jsx-runtime";function KZ({insetX:$,insetY:Y,onSelect:X,presence:Z}){if(!Z)return null;return R2("div",{"aria-label":"Presence",className:"documint-presence-indicators",style:{paddingRight:`${$}px`,top:`${Y}px`},children:Z.map((J)=>R2(UG,{onSelect:()=>X(J),presence:J},J.id))})}function UG({onSelect:$,presence:Y}){let X=Y.viewport,Z=GG(Y),J=X?.status==="above"?B4:O4,K=X!==null&&X.status!=="unresolved",Q=X?.status==="above"||X?.status==="below";return NG("button",{"aria-label":VG(Y),className:"documint-presence-indicator","data-status":X?.status??"unresolved",disabled:!K,onClick:K?$:void 0,style:{"--documint-presence-color":Y.color??"var(--documint-leaf-accent)"},type:"button",children:[R2("span",{className:"documint-presence-indicator-avatar",children:Y.avatarUrl?R2("img",{alt:"","aria-hidden":"true",className:"documint-presence-indicator-image",draggable:!1,src:Y.avatarUrl}):Z}),Q?R2("span",{className:"documint-presence-indicator-direction","aria-hidden":"true",children:R2(J,{className:"documint-presence-indicator-arrow",size:14,strokeWidth:2.3})}):null]})}function GG($){return QZ($).charAt(0).toLocaleUpperCase()}function VG($){let Y=QZ($),X=$.viewport?.status??"unresolved";if(X==="above")return`${Y} above viewport`;if(X==="below")return`${Y} below viewport`;if(X==="unresolved")return`${Y} unresolved`;return`${Y} in viewport`}function QZ($){return($.fullName??$.username).trim()||"Presence"}var l=`
|
|
29
|
+
`,b2="<ins>",r4="</ins>",S2=">",s4="```",y6=":::",T6="documint-comments";var o4="\\",w6="`",GZ=":",i4=" ",$9="![",Y9="[",VZ="(",MZ=")",qZ=/[\p{L}\p{N}]/u,AG=/[A-Za-z]/,_G=/[-A-Za-z0-9_]/,j6=/\{width=([1-9]\d*)\}/y,HG=/\\([\\`*_[\]{}()#+\-.!~|])/g,NZ=/\\(.)/g,AZ=[{delimiter:"**",mark:"bold",requireWordBoundary:!1},{delimiter:"~~",mark:"strikethrough",requireWordBoundary:!1},{delimiter:"*",mark:"italic",requireWordBoundary:!1},{delimiter:"_",mark:"italic",requireWordBoundary:!0}],zG=new Set(AZ.map(($)=>$.delimiter[0]));function n4($){return O6($,0,$.length,[])}function O6($,Y,X,Z){let J=[],K=Y,Q=Y;while(K<X){let M=FG($,K,X,Z);if(M){let D=Math.max(Q,K-(M.trimLeading??0));DZ(J,$.slice(Q,D),Z),J.push(...M.nodes),K=M.end,Q=K;continue}if($[K]===o4){K+=Math.min(2,X-K);continue}K+=1}return DZ(J,$.slice(Q,X),Z),Z0(J)}function FG($,Y,X,Z){let J=$[Y];switch(J){case GZ:return EG($,Y,X);case"<":return TG($,Y,X)??WG($,Y,X,Z)??PG($,Y,X);case o4:return jG($,Y,X);case l:return wG($,Y);case w6:return OG($,Y,X);case"!":return BG($,Y,X);case Y9:return CG($,Y,X,Z)}if(J!==void 0&&zG.has(J))return RG($,Y,X,Z);return null}function EG($,Y,X){if($[Y]!==GZ||!AG.test($[Y+1]??""))return null;let Z=Y+2;while(Z<X&&_G.test($[Z]??""))Z+=1;let J=UZ($,Z,X,"[","]"),Q=UZ($,J?.end??Z,X,"{","}")?.end??J?.end??Z;return{end:Q,nodes:[FZ("textDirective",$.slice(Y,Q))]}}function WG($,Y,X,Z){if(!$.startsWith(b2,Y))return null;let J=$.indexOf(r4,Y+b2.length);if(J<0||J>=X)return null;return{end:J+r4.length,nodes:O6($,Y+b2.length,J,[...Z,"underline"])}}function PG($,Y,X){if($[Y]!=="<")return null;let Z=$.indexOf(">",Y+1);if(Z<0||Z>=X)return null;return{end:Z+1,nodes:[FZ("html",$.slice(Y,Z+1))]}}var yG=/^<br\s*\/?>/i;function TG($,Y,X){if($[Y]!=="<")return null;let Z=yG.exec($.slice(Y,X));if(!Z)return null;let J=Y+Z[0].length;return{end:$[J]===l?J+1:J,nodes:[l0()]}}function jG($,Y,X){if($[Y]!==o4||$[Y+1]!==l||Y+1>=X)return null;return{end:Y+2,nodes:[l0()]}}function wG($,Y){if($[Y]!==l||$[Y-1]!==i4||$[Y-2]!==i4)return null;let X=0;while($[Y-1-X]===i4)X+=1;return{end:Y+1,nodes:[l0()],trimLeading:X}}function OG($,Y,X){if($[Y]!==w6)return null;let Z=1;while(Y+Z<X&&$[Y+Z]===w6)Z+=1;let J=w6.repeat(Z),K=$.indexOf(J,Y+Z);if(K<0||K>=X)return null;return{end:K+Z,nodes:[e1({code:$.slice(Y+Z,K)})]}}function BG($,Y,X){if(!$.startsWith($9,Y))return null;let Z=HZ($,Y+1,X);if(Z<0||$[Z+1]!==VZ)return null;let J=_Z($,Z+1,X);if(!J)return null;let K=LG($,J.end,X);return{end:K?.end??J.end,nodes:[j1({alt:zZ($.slice(Y+$9.length,Z)),title:J.title,url:J.url,width:K?.width??null})]}}function CG($,Y,X,Z){if($[Y]!==Y9||$.startsWith($9,Y-1))return null;let J=HZ($,Y,X);if(J<0||$[J+1]!==VZ)return null;let K=_Z($,J+1,X);if(!K)return null;return{end:K.end,nodes:[$2({children:O6($,Y+Y9.length,J,Z),title:K.title,url:K.url})]}}function _Z($,Y,X){let Z=e3($,Y+1,X),J=Z;while(J<X&&$[J]!==MZ&&$[J]!==i4){if($[J]===o4){J+=2;continue}J+=1}if(J===Z)return null;let K=bG($.slice(Z,J));Z=e3($,J,X);let Q=null;if(Z<X&&$[Z]==='"'){let M=B6($,'"',Z+1,X);if(M<0)return null;Q=$.slice(Z+1,M).replace(NZ,"$1"),Z=e3($,M+1,X)}if($[Z]!==MZ)return null;return{end:Z+1,title:Q,url:K}}function LG($,Y,X){j6.lastIndex=Y;let Z=j6.exec($);if(!Z||j6.lastIndex>X)return null;return{end:j6.lastIndex,width:Number(Z[1])}}function RG($,Y,X,Z){for(let J of AZ){if(!$.startsWith(J.delimiter,Y))continue;let K=B6($,J.delimiter,Y+J.delimiter.length,X);if(K<0)continue;if(J.requireWordBoundary){let M=Y>0?$[Y-1]:"",D=$[K+J.delimiter.length]??"";if(qZ.test(M)||qZ.test(D))continue}let Q=Y+J.delimiter.length;return{end:K+J.delimiter.length,nodes:O6($,Q,K,[...Z,J.mark])}}return null}function DZ($,Y,X){if(Y.length===0)return;$.push(q1({marks:X,text:zZ(Y)}))}function UZ($,Y,X,Z,J){if($[Y]!==Z)return null;let K=B6($,J,Y+1,X);if(K<0)return null;return{end:K+1}}function HZ($,Y,X){return B6($,"]",Y+1,X)}function B6($,Y,X,Z){for(let J=X;J<Z;J+=1){if($[J]===o4){J+=1;continue}if($.startsWith(Y,J))return J}return-1}function e3($,Y,X){while(Y<X&&$[Y]===i4)Y+=1;return Y}function zZ($){return $.replace(HG,"$1")}function bG($){return $.replace(NZ,"$1")}function FZ($,Y){return z5({originalType:$,source:Y})}var SG=/^:?-+:?$/;function WZ($,Y){let X=q0($),Z=Z9($,1),J=z0(X,Y),K=z0(Z,Y);if(!EZ(J)||!X9(K))return null;let Q=[C6(J)],M=vG(K);$.index+=2;while($.index<$.lines.length){let D=q0($),q=z0(D,Y);if(P1(D)||!EZ(q))break;Q.push(C6(q)),$.index+=1}return B1({align:M,rows:Q.map((D)=>Y2({cells:D.map((q)=>D1({children:n4(q)}))}))})}function X9($){let Y=C6($);return Y.length>0&&Y.every((X)=>SG.test(X.trim()))}function EZ($){let Y=$.trim();return Y.startsWith("|")&&Y.endsWith("|")}function vG($){return C6($).map((Y)=>{let X=Y.trim();if(X.startsWith(":")&&X.endsWith(":"))return"center";if(X.startsWith(":"))return"left";if(X.endsWith(":"))return"right";return null})}function C6($){let Y=$.trim();if(!Y.startsWith("|")||!Y.endsWith("|"))return[];return Y.slice(1,-1).split("|").map((X)=>X.trim())}var fG=3,PZ=/^(#{1,6})\s+(.*)$/,mG=/\s+#+\s*$/u,hG=/^(\s*)([-+*]|\d+\.)(?:\s+(.*)|\s*)$/,kG=/^\d+\.$/,uG=/^\[( |x|X)\](?:\s|$)/,yZ=/^```([^\s`]*)?(?:\s+(.*))?$/,TZ=/^:::([A-Za-z][-\w]*)(.*)$/,gG=[/^(\*\s*){3,}$/,/^(-\s*){3,}$/,/^(_\s*){3,}$/];function R6($,Y,X){let Z=[];while($.index<$.lines.length){let J=q0($);if($.index===$.lines.length-1&&J==="")break;if(P1(J)){$.index+=1;continue}if(v2(J)>Y+fG)break;let K=IG($,Y,X);if(!K)break;Z.push(K)}return Z}function IG($,Y,X){return pG($,Y,X)??xG($,Y)??lG($,Y)??cG($,Y)??aG($,Y)??WZ($,Y)??rG($,Y,X)??iG($,Y)??oG($,Y)}function pG($,Y,X){let Z=q0($);if(!z0(Z,Y).startsWith(S2))return null;let J=[];while($.index<$.lines.length){let K=q0($),Q=v2(K);if(P1(K)){J.push(""),$.index+=1;continue}if(Q<Y)break;let M=z0(K,Y);if(!M.startsWith(S2))break;let D=M.slice(1);if(D.startsWith(" "))D=D.slice(1);J.push(D),$.index+=1}return R0({children:R6({index:0,lines:J},0,X)})}function xG($,Y){let X=q0($),Z=z0(X,Y),J=yZ.exec(Z);if(!J)return null;$.index+=1;let K=[];while($.index<$.lines.length){let Q=q0($),M=z0(Q,Y);if(M.trim()===s4){$.index+=1;break}K.push(M),$.index+=1}return t6({language:J[1]?J[1]:null,meta:J[2]?J[2]:null,source:K.join(l)})}function lG($,Y){let X=q0($),Z=z0(X,Y),J=TZ.exec(Z);if(!J)return null;let K=J[1],Q=[];$.index+=1;while($.index<$.lines.length){let M=q0($),D=z0(M,Y);if(D.trim()===y6){$.index+=1;break}Q.push(D),$.index+=1}return a9({attributes:dG(J[2]??""),body:Q.join(l),name:K})}function dG($){let Y=$.trim();if(Y.startsWith("{")&&Y.endsWith("}"))return Y.slice(1,-1);return Y}function cG($,Y){let X=q0($),Z=PZ.exec(z0(X,Y));if(!Z)return null;return $.index+=1,H5({children:n4(Z[2].replace(mG,"")),depth:Z[1].length})}function aG($,Y){let X=z0(q0($),Y).trim();if(!jZ(X))return null;return $.index+=1,F5()}function rG($,Y,X){let Z=L6(q0($),Y);if(!Z)return null;let J=[],K=!1;while($.index<$.lines.length){let Q=q0($),M=L6(Q,Y);if(!M||M.ordered!==Z.ordered)break;$.index+=1;let D=[M.content],q=!1;while($.index<$.lines.length){let U=q0($),V=v2(U);if(P1(U)){let G=eG($.lines,$.index+1);if(G<0||v2($.lines[G]??"")<=Y)break;q=!0,D.push(""),$.index+=1;continue}if(V<M.contentIndent)break;if(V===Y&&L6(U,Y))break;D.push(tG(U,M.contentIndent)),$.index+=1}K||=q,J.push(w1({checked:M.checked,children:sG(D,X),spread:q}))}return O1({items:J,ordered:Z.ordered,spread:K,start:Z.ordered&&X.preserveOrderedListStart?Z.start??1:null})}function L6($,Y){let X=hG.exec($);if(!X||X[1].length!==Y)return null;let Z=X[2],J=kG.test(Z),K=J?Number(Z.slice(0,-1)):null,Q=X[3]??"",M=null;if(uG.test(Q)){if(M=Q[1]==="x"||Q[1]==="X",Q=Q.slice(3),Q.startsWith(" "))Q=Q.slice(1)}let D=X[0].length-X[1].length-X[2].length-Q.length;return{checked:M,content:Q,contentIndent:Y+X[2].length+D,ordered:J,start:K}}function sG($,Y){let X=R6({index:0,lines:$},0,Y);if(X.length>0)return X;return[x0({children:[]})]}function iG($,Y){let X=z0(q0($),Y).trim();if(!wZ(X))return null;return $.index+=1,e6({originalType:"html",source:X})}function oG($,Y){let X=[];while($.index<$.lines.length){let Z=q0($),J=v2(Z);if(P1(Z))break;if(J<Y)break;let K=z0(Z,Y);if(X.length>0&&nG(Z,K,Y))break;X.push(K),$.index+=1}return x0({children:n4(X.join(l))})}function nG($,Y,X){let Z=Y.trim();return Y.startsWith(S2)||yZ.test(Y)||TZ.test(Y)||PZ.test(Y)||jZ(Z)||X9(Y)||L6($,X)!==null||wZ(Z)}function v2($){let Y=0;while(Y<$.length&&$[Y]===" ")Y+=1;return Y}function tG($,Y){let X=v2($);if(X>=Y)return $.slice(Y);return $.trim()===""?"":$.slice(Math.min(X,Y))}function eG($,Y){for(let X=Y;X<$.length;X+=1)if(!P1($[X]??""))return X;return-1}function jZ($){return gG.some((Y)=>Y.test($))}function wZ($){return $.startsWith("<")&&$.endsWith(">")}function BZ($){let Y=$.at(-1),X=Y&&OZ(Y)?Y:null;return{blocks:$.filter((J)=>!OZ(J)),comments:X?$V(X.body):[]}}function $V($){let Y;try{Y=JSON.parse($)}catch{return[]}if(!Array.isArray(Y))return[];return Y.flatMap((X)=>{let Z=A8(X);return Z?[Z]:[]})}function OZ($){return $.type==="directive"&&$.name===T6}var CZ="---";function t4($,Y={}){let Z={index:0,lines:$.replace(/\r\n/g,l).split(l)},J=YV(Z),K=R6(Z,0,Y),{comments:Q,blocks:M}=BZ(K);return J2(M,Q,J)}function YV($){if($.lines[0]!==CZ)return;for(let Y=1;Y<$.lines.length;Y+=1)if($.lines[Y]===CZ){let X=$.lines.slice(0,Y+1).join(l);return $.index=Y+1,X}return}function q0($){return Z9($,0)}function Z9($,Y){return $.lines[$.index+Y]??""}function P1($){return $.trim()===""}function z0($,Y){return $.slice(Y)}var XV=/([\\`*_[\]])/g,ZV=/([\\)&])/g,JV=/(["\\])/g;function i0($){return Z0($).map((Y)=>KV(Y)).join("")}function KV($){switch($.type){case"lineBreak":return"<br>";case"image":return qV($);case"code":return MV($.code);case"link":return DV($);case"text":return QV(RZ($.text),$.marks);case"raw":return $.source}}function QV($,Y){return Y.reduce((X,Z)=>{switch(Z){case"bold":return`**${X}**`;case"italic":return`*${X}*`;case"strikethrough":return`~~${X}~~`;case"underline":return`${b2}${X}${r4}`}},$)}function MV($){let Y=0,X=0;for(let Q of $){if(Q==="`"){if(X+=1,X>Y)Y=X;continue}X=0}let Z=Y>0?Y+1:1,J="`".repeat(Z),K=$.startsWith("`")||$.endsWith("`")?` ${$} `:$;return`${J}${K}${J}`}function qV($){let Y=RZ($.alt??""),X=LZ($.url,$.title),Z=$.width?`{width=${$.width}}`:"";return`![${Y}]${X}${Z}`}function DV($){return`[${i0($.children)}]${LZ($.url,$.title)}`}function LZ($,Y){return`(${UV($)}${GV(Y)})`}function RZ($){return $.replace(XV,"\\$1")}function UV($){return $.replace(ZV,"\\$1")}function GV($){return $?` "${$.replace(JV,"\\$1")}"`:""}var SZ=3;function vZ($,Y,X){let Z=$.rows.map((U)=>U.cells.map((V)=>i0(V.children))),J=Math.max(1,...Z.map((U)=>U.length)),K=Z[0]??[],Q=Array.from({length:J},(U,V)=>Math.max(_V($.align[V]),...X.padTableColumns?Z.map((G)=>G[V]?.length??0):[K[V]?.length??0])),M=VV(Q,$.align,Y),D=bZ(K,Q,$.align,Y,X),q=Z.slice(1).map((U)=>bZ(U,Q,$.align,Y,X));return[D??NV(Q,Y),M,...q].join(l)}function bZ($,Y,X,Z,J){let K=Y.map((Q,M)=>{let D=$[M]??"";if(!J.padTableColumns)return D;return HV(D,Q,X[M])});return`${" ".repeat(Z)}| ${K.join(" | ")} |`}function VV($,Y,X){let Z=$.map((J,K)=>AV(Y[K],J));return`${" ".repeat(X)}| ${Z.join(" | ")} |`}function NV($,Y){return`${" ".repeat(Y)}| ${$.map((X)=>"".padEnd(X," ")).join(" | ")} |`}function AV($,Y){let X=fZ($),Z=Math.max(SZ,Y-X),J="-".repeat(Z);switch($){case"center":return`:${J}:`;case"left":return`:${J}`;case"right":return`${J}:`;default:return J}}function _V($){return SZ+fZ($)}function fZ($){if($==="center")return 2;return $?1:0}function HV($,Y,X){if(X==="right")return $.padStart(Y," ");return $.padEnd(Y," ")}var x1=`
|
|
30
|
+
|
|
31
|
+
`,zV="-",FV=".",EV="---",WV=" ";function e4($,Y={}){return $.map((X)=>b6(X,0,Y)).join(x1)}function b6($,Y,X){let Z=l1(Y);switch($.type){case"blockquote":return PV($,Y,X);case"code":return yV($,Y);case"directive":return TV($,Y);case"heading":return mZ($,Y);case"list":return jV($,Y,X);case"listItem":return hZ($,Y,!1,1,X);case"paragraph":return`${Z}${J9(i0($.children))}`;case"table":return vZ($,Y,X);case"divider":return`${Z}${EV}`;case"raw":return Y===0?$.source:kZ($.source,Y)}}function PV($,Y,X){let Z=$.children.map((K)=>b6(K,0,X)).join(x1),J=l1(Y);return Z.split(l).map((K)=>`${J}${S2}${K.length>0?` ${K}`:""}`).join(l)}function yV($,Y){let X=[$.language??"",$.meta??""].filter(Boolean).join(" ").trim(),Z=l1(Y),J=`${Z}${s4}${X?X:""}`,K=$.source.length>0?$.source.split(l).map((Q)=>`${Z}${Q}`).join(l):Z;return`${J}${l}${K}${l}${Z}${s4}`}function TV($,Y){let X=S6($);return Y===0?X:kZ(X,Y)}function S6($){let Y=$.attributes?`{${$.attributes}}`:"";return`:::${$.name}${Y}${l}${$.body}${l}${y6}`}function mZ($,Y){let X=J9(i0($.children)),Z=`${l1(Y)}${"#".repeat($.depth)}`;return X.length>0?`${Z} ${X}`:Z}function jV($,Y,X){let Z=$.start??1;return $.items.map((J)=>hZ(J,Y,$.ordered,Z,X)).join($.spread?x1:l)}function hZ($,Y,X,Z,J){let K=X?`${Z}${FV}`:zV,Q=$.checked===null?"":`[${$.checked?"x":" "}] `,M=`${l1(Y)}${K} ${Q}`,D=Y+K.length+1,q=$.children;if(q.length===0)return Q.length>0?M:M.trimEnd();let[U,...V]=q,G=wV(U,M,Q.length>0,J),N=V.map((A)=>b6(A,D,J)).join($.spread?x1:l);if(!N)return G;return`${G}${$.spread?x1:l}${N}`}function wV($,Y,X,Z){switch($.type){case"paragraph":{let J=J9(i0($.children));if(J.length===0)return X?Y:Y.trimEnd();return`${Y}${J}`}case"heading":return`${Y}${mZ($,0)}`;case"directive":case"raw":{let J=$.type==="directive"?S6($):$.source,[K,...Q]=J.split(l);return[Y+K,...Q.map((M)=>`${l1(Y.length)}${M}`)].join(l)}default:{let J=Y.length;return`${Y.trimEnd()}${l}${b6($,J,Z)}`}}}function J9($){return $.replace(/^ +/gm,(Y)=>WV.repeat(Y.length))}function l1($){return" ".repeat($)}function kZ($,Y){let X=l1(Y);return $.split(l).map((Z)=>`${X}${Z}`).join(l)}function v6($,Y={}){if($.blocks.length===0&&$.comments.length===0&&$.frontMatter===void 0)return"";let X=[];if($.frontMatter!==void 0)X.push($.frontMatter);if($.blocks.length>0)X.push(e4($.blocks,Y));if($.comments.length>0)X.push(OV($.comments));let Z=X.join(x1);return Z.endsWith(l)?Z:`${Z}${l}`}function OV($){return S6({attributes:"",body:JSON.stringify($,null,2),name:T6})}function K9($){if($.length===0)return{kind:"text",text:""};let{blocks:Y}=t4($);if(P5(Y))return{kind:"text",text:Y[0]?.plainText??""};if(Y.length===1&&Y[0]?.type==="paragraph")return{kind:"inlines",inlines:Y[0].children};return{kind:"blocks",blocks:Y}}function f6($){switch($.kind){case"text":return $.text;case"inlines":return i0($.inlines);case"blocks":return e4($.blocks)}}import{createContext as BV,useContext as CV}from"react";import{createPortal as LV}from"react-dom";import{jsx as IZ}from"react/jsx-runtime";var uZ=BV(void 0);function gZ({children:$,themeStyles:Y}){return IZ(uZ.Provider,{value:Y,children:$})}function m6({children:$}){let Y=CV(uZ);if(typeof document>"u")return null;return LV(IZ("div",{className:"documint-overlay",style:{display:"contents",...Y},children:$}),document.body)}import{useEffect as h6,useRef as $J,useState as d1}from"react";import{forwardRef as bV,useCallback as f2,useEffect as SV,useImperativeHandle as vV,useLayoutEffect as fV,useMemo as mV,useRef as lZ,useState as Q9}from"react";var RV=["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 pZ($,Y,{topGap:X=8}={}){if(!$.isConnected)return null;let Z=getComputedStyle($),J=document.createElement("div");for(let q of RV)J.style.setProperty(q,Z.getPropertyValue(q));Object.assign(J.style,{position:"absolute",top:"0",left:"0",visibility:"hidden",whiteSpace:"pre-wrap",wordWrap:"break-word",width:`${$.clientWidth}px`}),J.textContent=$.value.slice(0,Y);let K=document.createElement("span");K.textContent=$.value.slice(Y)||".",J.appendChild(K),document.body.appendChild(J);let Q=$.getBoundingClientRect(),M=parseFloat(Z.lineHeight)||K.offsetHeight,D={left:Q.left+K.offsetLeft+parseFloat(Z.borderLeftWidth)-$.scrollLeft,top:Q.top+K.offsetTop+parseFloat(Z.borderTopWidth)+M+X-$.scrollTop};return document.body.removeChild(J),D}import{jsx as h0,jsxs as dZ,Fragment as dV}from"react/jsx-runtime";var hV=240,kV="documint-leaf-menu-item documint-completion-item",$5=bV(function({actions:Y,completionSources:X,onChange:Z,placeholder:J,readOnly:K=!1,rows:Q=3,value:M},D){let q=lZ(null);vV(D,()=>q.current,[]);let U=mV(()=>pV(X),[X]),[V,G]=Q9(null),[N,A]=Q9(0),[_,z]=Q9(null),F=f2((P,y)=>{if(!U.length){G(null);return}let E=xV(P,y,U);if(!E){G(null);return}G(E),A(0)},[U]),B=f2((P)=>{let y=P.currentTarget.value,E=P.currentTarget.selectionEnd??y.length;Z(y),F(y,E)},[Z,F]),W=f2((P)=>{let y=P.currentTarget;F(y.value,y.selectionEnd??y.value.length)},[F]),S=f2(()=>{G(null)},[]),b=f2((P)=>{if(!q.current||!V)return;let E=`${V.trigger}${P.label} `,w=M.slice(0,V.triggerStart),C=M.slice(V.caret),T=w+E+C,H=V.triggerStart+E.length;Z(T),G(null),requestAnimationFrame(()=>{let R=q.current;if(!R)return;R.focus(),R.setSelectionRange(H,H)})},[V,Z,M]),k=f2((P)=>{if(V&&V.matches.length>0){if(P.key==="ArrowDown"){P.preventDefault(),P.stopPropagation(),A((y)=>(y+1)%V.matches.length);return}if(P.key==="ArrowUp"){P.preventDefault(),P.stopPropagation(),A((y)=>(y-1+V.matches.length)%V.matches.length);return}if(P.key==="Enter"||P.key==="Tab"){P.preventDefault(),P.stopPropagation();let y=V.matches[N];if(y)b(y);return}if(P.key==="Escape"){P.preventDefault(),P.stopPropagation(),G(null);return}}if(P.key==="Escape"&&Y.kind==="edit")P.preventDefault(),Y.onCancel()},[Y,V,N,b]);return fV(()=>{if(!V){z(null);return}let P=()=>{let y=q.current;if(!y)return;z(pZ(y,V.triggerStart))};return P(),window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}},[V]),dZ("div",{className:"documint-leaf-input-field",children:[h0("textarea",{className:"documint-leaf-input",onBlur:S,onChange:B,onKeyDown:k,onSelect:W,placeholder:J,readOnly:K,ref:q,rows:Q,value:M}),uV(Y),V&&_&&V.matches.length>0?h0(m6,{children:h0(gV,{activeIndex:N,left:_.left,matches:V.matches,onHover:A,onSelect:b,top:_.top})}):null]})});function uV($){if($.kind==="edit")return dZ(dV,{children:[h0(M9,{className:"documint-leaf-input-cancel",icon:a4,label:"Cancel editing",onClick:$.onCancel}),h0(M9,{className:"documint-leaf-input-save",disabled:$.saveDisabled??!1,icon:I1,label:"Save",onClick:$.onSave})]});return h0(M9,{className:"documint-leaf-input-submit",disabled:$.submitDisabled??!1,icon:E1,iconSize:15,label:$.submitLabel,onClick:$.onSubmit})}function M9({className:$,disabled:Y=!1,icon:X,iconSize:Z=14,label:J,onClick:K}){return h0("button",{"aria-label":J,className:`documint-leaf-action ${$}`,disabled:Y,onClick:K,title:J,type:"button",children:h0(X,{size:Z,strokeWidth:2.2})})}function gV({activeIndex:$,left:Y,matches:X,onHover:Z,onSelect:J,top:K}){let Q=lZ(null);return SV(()=>{let M=Q.current;if(!M)return;let D=M.children[$];if(D instanceof HTMLElement)D.scrollIntoView({block:"nearest"})},[$]),h0("div",{className:"documint-leaf-menu documint-completion-popover",ref:Q,role:"listbox",style:{position:"fixed",left:Y,top:K,maxHeight:hV,overflowY:"auto"},children:X.map((M,D)=>{let q=D===$;return h0("button",{"aria-selected":q,className:`${kV}${q?" is-active":""}`,onPointerDown:IV,onPointerEnter:()=>Z(D),onClick:()=>J(M),role:"option",type:"button",children:h0("span",{children:M.label})},M.label)})})}function IV($){$.preventDefault()}function pV($){if(!$?.length)return[];return $.map((Y)=>({trigger:Y.trigger,items:[...Y.items].sort((X,Z)=>X.label.localeCompare(Z.label,void 0,{sensitivity:"base"}))}))}function xV($,Y,X){for(let Z=Y-1;Z>=0;Z-=1){let J=$[Z];if(xZ(J))return null;let K=X.find((M)=>M.trigger===J);if(!K)continue;if(Z>0&&!xZ($[Z-1]))return null;let Q=$.slice(Z+1,Y);return{trigger:K.trigger,query:Q,triggerStart:Z,caret:Y,matches:lV(K.items,Q)}}return null}function xZ($){return $===void 0||$===" "||$===`
|
|
32
|
+
`||$==="\t"}function lV($,Y){if(!Y)return $;let X=Y.toLowerCase();return $.filter((Z)=>Z.label.toLowerCase().includes(X))}import{Fragment as aV}from"react";function q9($,Y){if(!Y?.length||!Y.some((Q)=>$.includes(Q.trigger)))return[{kind:"text",text:$}];let X=new Map;for(let Q of Y){let M=[...Q.items].sort((D,q)=>q.label.length-D.label.length);X.set(Q.trigger,M)}let Z=[],J=0,K=0;while(J<$.length){let Q=$[J],M=X.get(Q);if(M!==void 0&&(J===0||cV($[J-1]))){let q=M.find((U)=>$.startsWith(U.label,J+1));if(q){if(J>K)Z.push({kind:"text",text:$.slice(K,J)});Z.push({kind:"token",trigger:Q,label:q.label,id:q.id}),J+=1+q.label.length,K=J;continue}}J+=1}if(K<$.length)Z.push({kind:"text",text:$.slice(K)});return Z}function D9($,Y){let X=[],Z=new Set;for(let J of q9($,Y)){if(J.kind!=="token"||J.trigger!=="@"||!J.id)continue;if(Z.has(J.id))continue;Z.add(J.id),X.push(J.id)}return X}function cV($){return $===void 0||$===" "||$===`
|
|
33
|
+
`||$==="\t"}import{jsx as cZ,jsxs as sV}from"react/jsx-runtime";function U9({value:$,completionSources:Y,onEdit:X}){return cZ("p",{onDoubleClick:X,children:rV($,Y)})}function rV($,Y){let X=q9($,Y);if(X.length===1&&X[0].kind==="text")return $;return X.map((Z,J)=>Z.kind==="token"?sV("span",{className:"documint-mention",children:[Z.trigger,Z.label]},J):cZ(aV,{children:Z.text},J))}import{Children as aZ,isValidElement as rZ,useEffect as iV,useRef as oV,useState as nV}from"react";import{jsx as V0,jsxs as N9}from"react/jsx-runtime";var G9=($)=>{$.preventDefault()},V9=($)=>$.isPrimary&&$.button===0;function tV({children:$}){return V0("div",{className:"documint-leaf-toolbar",children:aZ.map($,eV)})}function eV($){if(!rZ($))return null;if($.type===iZ){let Y=$.props;return V0(sZ,{children:V0($N,{...Y})})}if($.type===oZ){let{className:Y}=$.props;return V0("div",{className:Y5("documint-leaf-toolbar-divider",Y)})}if($.type===nZ){let Y=$.props;return V0(YN,{...Y})}return null}function $N({active:$=!1,className:Y,disabled:X=!1,icon:Z,label:J,onClick:K}){return V0("button",{"aria-label":J,className:Y5("documint-leaf-toolbar-button",$?"active":null,Y),disabled:X,onPointerDown:(Q)=>{if(G9(Q),!X&&V9(Q))K()},title:J,type:"button",children:V0(Z,{size:15,strokeWidth:2.2})})}function YN({children:$,className:Y,icon:X,label:Z,onSelect:J}){let K=oV(null),[Q,M]=nV(!1);return iV(()=>{if(!Q)return;let D=(q)=>{if(K.current&&q.target instanceof Node&&!K.current.contains(q.target))M(!1)};return window.addEventListener("pointerdown",D),()=>{window.removeEventListener("pointerdown",D)}},[Q]),V0(sZ,{children:N9("div",{className:"documint-leaf-toolbar-menu-shell",ref:K,children:[V0(XN,{className:Y,icon:X,isOpen:Q,label:Z,onClick:()=>M((D)=>!D)}),Q?V0("div",{className:"documint-leaf-menu",role:"menu",children:aZ.map($,(D)=>ZN(D,(q)=>{M(!1),J(q)}))}):null]})})}function XN({className:$,icon:Y,isOpen:X,label:Z,onClick:J}){return N9("button",{"aria-expanded":X,"aria-haspopup":"menu","aria-label":Z,className:Y5("documint-leaf-toolbar-button",X?"active":null,$),onPointerDown:(K)=>{if(G9(K),V9(K))J()},title:Z,type:"button",children:[V0(Y,{size:15,strokeWidth:2.2}),V0(L4,{className:Y5("documint-leaf-toolbar-menu-chevron",X?"is-open":null),size:13,strokeWidth:2.2})]})}function ZN($,Y){if(!rZ($))return null;if($.type===eZ){let{className:Q}=$.props;return V0("div",{className:Y5("documint-leaf-menu-divider",Q),role:"separator"})}if($.type!==tZ)return null;let{disabled:X=!1,icon:Z,text:J,value:K}=$.props;return N9("button",{className:"documint-leaf-menu-item",disabled:X,onPointerDown:(Q)=>{if(G9(Q),!X&&V9(Q))Y(K)},role:"menuitem",type:"button",children:[V0(Z,{size:15,strokeWidth:2.2}),V0("span",{children:J})]})}function Y5(...$){return $.filter(Boolean).join(" ")}function sZ({children:$}){return V0("div",{className:"documint-leaf-toolbar-group",children:$})}function iZ($){return null}function oZ($){return null}function nZ($){return null}function tZ($){return null}function eZ($){return null}var d=Object.assign(tV,{Button:iZ,Divider:oZ,Menu:nZ,MenuDivider:eZ,MenuItem:tZ});import{jsx as o,jsxs as o0,Fragment as MN}from"react/jsx-runtime";var JN=!1,KN=220,c1=()=>{};function A9($){let Y=$.mode==="create",X=$.mode==="create"?$:null,Z=$.mode==="thread"?$:null,J=$.canEdit,K=$.link,Q=Z?.thread??null,M=Q?.comments??[],D=M[0]??null,q=Q?U1(Q):!1,U=Z?.animateInitialComment??!1,[V,G]=d1(null),[N,A]=d1(""),[_,z]=d1(""),[F,B]=d1(""),[W,S]=d1(!U),[b,k]=d1(JN),[P,y]=d1(!1),E=$J(null),w=$J(null),C=$.mentionSources,T=Q?P8(Q):null,H=T?YJ(T):"",R=J&&!q,u=R&&N.trim().length>0,g=R&&_.trim().length>0,I=J&&F.trim().length>0,j=Y||P,O=!Y||b,v=!Y&&Boolean(Q),f=Boolean(D),a=Y?b:!0,x=Z?.onDeleteComment??c1,E0=Z?.onDeleteThread??c1,t0=Z?.onToggleResolved??c1,u0=X?.activeMarks??[],g0=X?.onToggleBold??c1,e0=X?.onToggleItalic??c1,c6=X?.onToggleStrikethrough??c1,a6=X?.onToggleUnderline??c1,D5=J?Y?"Add a comment":"Reply to this comment":"Comment editing is disabled",r6=Y?F:_;h6(()=>{if(V!==null&&(V<0||V>=M.length))G(null),A("")},[M.length,V]),h6(()=>{if(!f||!U){S(!0);return}S(!1);let r=requestAnimationFrame(()=>{S(!0)});return()=>{cancelAnimationFrame(r)}},[U,D,f]),h6(()=>{if(!Z||!U){y(!1);return}y(!0);let r=window.setTimeout(()=>{y(!1)},KN);return()=>{window.clearTimeout(r)}},[U,Z]),h6(()=>{if(!Y||!b||!J)return;let r=requestAnimationFrame(()=>{w.current?.focus()});return()=>{cancelAnimationFrame(r)}},[J,Y,b]);let u2=()=>{G(null),A("")},U5=(r,G5)=>{if(!v||!R)return;G(r),A(G5)},I0=(r)=>{if(!Z)return;Z.onEditComment(r,N),u2()},w0=()=>{if(!Z)return;Z.onReply(_),z("")},s1=()=>{if(!X||!I)return;X.onCreateThread(F),B("")},s6=j?`documint-comment-leaf documint-comment-leaf-create${a?" is-expanded":""}`:"documint-comment-leaf",i1=v||f||O?o(QN,{canCreate:I,canEdit:J,canMutateThread:R,canReply:g,canSaveEditedComment:u,comments:M,composerRef:w,editDraft:N,editingCommentIndex:V,isComposerVisible:O,isInitialCommentVisible:W,isResolved:q,link:K,mentionSources:C,mode:$.mode,onBeginEditingComment:U5,onCancelEditing:u2,onChangeCreateDraft:B,onChangeEditDraft:A,onChangeReplyDraft:z,onDeleteComment:x,onDeleteThread:E0,onSubmitCreate:s1,onSubmitEditedComment:I0,onSubmitReply:w0,onToggleResolved:t0,rootComment:D,showRootComment:f,showThreadChrome:v,threadAge:H,composerPlaceholder:D5,composerValue:r6}):null;return o("div",{className:s6,ref:E,children:o0("div",{className:j?"documint-comment-leaf-create-shell":void 0,children:[j?o0(d,{children:[o(d.Button,{className:"documint-comment-leaf-create-button",icon:p4,label:"Add comment",onClick:()=>k(!0)}),o(d.Divider,{className:"documint-comment-leaf-create-divider"}),o(d.Button,{active:u0.includes("bold"),className:"documint-comment-leaf-create-mark",icon:C4,label:"Bold",onClick:g0}),o(d.Button,{active:u0.includes("italic"),className:"documint-comment-leaf-create-mark",icon:k4,label:"Italic",onClick:e0}),o(d.Button,{active:u0.includes("underline"),className:"documint-comment-leaf-create-mark",icon:c4,label:"Underline",onClick:a6}),o(d.Button,{active:u0.includes("strikethrough"),className:"documint-comment-leaf-create-mark",icon:l4,label:"Strikethrough",onClick:c6})]}):null,o("div",{className:j?"documint-comment-leaf-create-content":void 0,children:i1})]})})}function QN({canCreate:$,canEdit:Y,canMutateThread:X,canReply:Z,canSaveEditedComment:J,comments:K,composerRef:Q,editDraft:M,editingCommentIndex:D,isComposerVisible:q,isInitialCommentVisible:U,isResolved:V,link:G,mentionSources:N,mode:A,onBeginEditingComment:_,onCancelEditing:z,onChangeCreateDraft:F,onChangeEditDraft:B,onChangeReplyDraft:W,onDeleteComment:S,onDeleteThread:b,onSubmitCreate:k,onSubmitEditedComment:P,onSubmitReply:y,onToggleResolved:E,rootComment:w,showRootComment:C,showThreadChrome:T,threadAge:H,composerPlaceholder:R,composerValue:u}){return o0(MN,{children:[T?o0("div",{className:"documint-comment-leaf-header",children:[o("span",{className:"documint-comment-leaf-age",children:H}),o0("div",{className:"documint-comment-leaf-actions",children:[o("button",{className:"documint-leaf-action","aria-label":V?"Reopen comment":"Resolve comment",disabled:!Y,onClick:E,title:V?"Reopen comment":"Resolve comment",type:"button",children:o(I1,{size:14,strokeWidth:2.2})}),o("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment thread",disabled:!Y,onClick:b,title:"Delete comment thread",type:"button",children:o(L0,{size:14,strokeWidth:2.2})})]})]}):null,T&&G?o0("div",{className:"documint-comment-leaf-link",children:[G.title?o("div",{className:"documint-link-leaf-title",children:G.title}):null,o("div",{className:"documint-link-leaf-url",children:G.url})]}):null,o0("div",{className:`documint-comment-thread${C?"":" is-empty"}`,children:[o("article",{className:C?`documint-comment-message documint-comment-message-root${U?" is-visible":""}`:"documint-comment-message documint-comment-message-root is-hidden",children:w?o(U9,{completionSources:N,onEdit:()=>_(0,w.body),value:w.body}):null}),K.slice(1).map((g,I)=>{let j=I+1,O=D===j;return o0("article",{className:"documint-comment-message",children:[!O?o0("div",{className:"documint-comment-message-meta",children:[o("span",{children:YJ(g.updatedAt)}),X?o0("div",{className:"documint-comment-leaf-actions",children:[o("button",{className:"documint-leaf-action","aria-label":"Edit comment",disabled:!X,onClick:()=>{_(j,g.body)},title:"Edit comment",type:"button",children:o(p1,{size:14,strokeWidth:2.2})}),o("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Delete comment",disabled:!X,onClick:()=>S(j),title:"Delete comment",type:"button",children:o(L0,{size:14,strokeWidth:2.2})})]}):null]}):null,O?o($5,{actions:{kind:"edit",onCancel:z,onSave:()=>P(j),saveDisabled:!J},completionSources:N,onChange:B,readOnly:!Y,rows:3,value:M}):o(U9,{completionSources:N,onEdit:()=>_(j,g.body),value:g.body})]},`${g.updatedAt}:${j}`)})]}),o("div",{className:`documint-comment-reply${T?"":" is-standalone"}${q?" is-visible":""}`,children:o($5,{actions:A==="create"?{kind:"compose",onSubmit:k,submitDisabled:!$,submitLabel:"Create comment"}:{kind:"compose",onSubmit:y,submitDisabled:!Z,submitLabel:"Reply"},completionSources:N,onChange:A==="create"?F:W,placeholder:R,readOnly:!Y,ref:Q,rows:3,value:u})})]})}function YJ($){let Y=new Date($);if(Number.isNaN(Y.getTime()))return $;let X=Y.getTime()-Date.now(),Z=60000,J=60*Z,K=24*J,Q=7*K,M=30*K,D=365*K,q=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});if(Math.abs(X)<Z)return"just now";if(Math.abs(X)<J)return q.format(Math.round(X/Z),"minute");if(Math.abs(X)<K)return q.format(Math.round(X/J),"hour");if(Math.abs(X)<Q)return q.format(Math.round(X/K),"day");if(Math.abs(X)<D)return q.format(Math.round(X/M),"month");return q.format(Math.round(X/D),"year")}import{jsx as k0,jsxs as UN}from"react/jsx-runtime";var qN=[{icon:R4,label:"Heading 1",text:"# "},{icon:b4,label:"Heading 2",text:"## "},{icon:S4,label:"Heading 3",text:"### "},{icon:v4,label:"Heading 4",text:"#### "},{icon:f4,label:"Heading 5",text:"##### "},{icon:m4,label:"Heading 6",text:"###### "}],DN=[{columns:2,text:"2 columns"},{columns:3,text:"3 columns"},{columns:4,text:"4 columns"},{columns:5,text:"5 columns"}];function XJ({onInsert:$,onInsertTable:Y}){return UN(d,{children:[k0(d.Button,{icon:I4,label:"Insert bulleted list",onClick:()=>$("- ")}),k0(d.Button,{icon:u4,label:"Insert numbered list",onClick:()=>$("1. ")}),k0(d.Button,{icon:g4,label:"Insert task list",onClick:()=>$("- [ ] ")}),k0(d.Divider,{}),k0(d.Menu,{icon:h4,label:"Insert heading",onSelect:$,children:qN.map(({icon:X,label:Z,text:J})=>k0(d.MenuItem,{icon:X,text:Z,value:J},J))}),k0(d.Menu,{icon:W1,label:"Insert table",onSelect:(X)=>Y(Number(X)),children:DN.map(({columns:X,text:Z})=>k0(d.MenuItem,{icon:W1,text:Z,value:String(X)},X))}),k0(d.Divider,{}),k0(d.Button,{icon:d4,label:"Insert blockquote",onClick:()=>$("> ")}),k0(d.Button,{icon:x4,label:"Insert divider",onClick:()=>$("--- ")})]})}import{jsx as _9,jsxs as GN}from"react/jsx-runtime";function ZJ({anchor:$,children:Y,status:X="default"}){let Z=!$.isSelection;return _9(m6,{children:GN("div",{className:"documint-leaf-anchor","data-selection":$.isSelection?"true":"false",onPointerEnter:$.onPointerEnter,onPointerLeave:$.onPointerLeave,style:{left:`${$.left}px`,top:`${$.top}px`},children:[Z?_9("div",{className:"documint-leaf-bridge"}):null,_9("div",{className:"documint-leaf-shell","data-status":X,children:Y})]})})}import{useEffect as JJ,useRef as VN,useState as KJ}from"react";import{jsx as K1,jsxs as H9}from"react/jsx-runtime";function QJ({canEdit:$,onDelete:Y,onSave:X,title:Z,url:J}){let[K,Q]=KJ(J),[M,D]=KJ(!1),q=VN(null),U=NN(),V=K.trim(),G=$&&V.length>0,N=$&&!M,A=`${U}click to open`,_=`documint-link-leaf-row${M?" is-editing":""}`;return JJ(()=>{if(M)return;Q(J)},[M,J]),JJ(()=>{if(!M)return;q.current?.focus()},[M]),H9("div",{className:"documint-link-leaf",children:[Z?K1("div",{className:"documint-link-leaf-title",children:Z}):null,H9("div",{className:_,children:[M?K1($5,{actions:{kind:"edit",onCancel:()=>{Q(J),D(!1)},onSave:()=>{X(V),D(!1)},saveDisabled:!G},onChange:Q,readOnly:!$,ref:q,rows:3,value:K}):K1("div",{className:"documint-link-leaf-url",children:J}),N?H9("div",{className:"documint-link-leaf-actions",children:[K1("button",{className:"documint-leaf-action","aria-label":"Edit link",onClick:()=>{if(!$)return;Q(J),D(!0)},title:"Edit link",type:"button",children:K1(p1,{size:14,strokeWidth:2.2})}),K1("button",{className:"documint-leaf-action documint-leaf-action-danger","aria-label":"Remove link",onClick:Y,title:"Remove link",type:"button",children:K1(L0,{size:14,strokeWidth:2.2})})]}):null]}),K1("div",{className:"documint-link-leaf-divider"}),K1("div",{className:"documint-link-leaf-hint",children:A})]})}function NN(){if(typeof navigator>"u")return"Ctrl+";let $=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test($)?"CMD+":"CTRL+"}import{jsx as Q1,jsxs as E9}from"react/jsx-runtime";var AN=[{text:"Column left",value:"left"},{text:"Column right",value:"right"}],_N=[{text:"Row above",value:"above"},{text:"Row below",value:"below"}],z9={text:"Delete column",value:"delete"},F9={text:"Delete row",value:"delete"},MJ={text:"Delete table",value:"delete"};function qJ({canDeleteColumn:$,canDeleteRow:Y,onDeleteColumn:X,onDeleteRow:Z,onDeleteTable:J,onInsertColumn:K,onInsertRow:Q}){return E9(d,{children:[E9(d.Menu,{icon:z1,label:"Column actions",onSelect:(M)=>{if(M===z9.value){X();return}K(M)},children:[AN.map(({text:M,value:D})=>Q1(d.MenuItem,{icon:L2,text:M,value:D},D)),Q1(d.MenuDivider,{}),Q1(d.MenuItem,{disabled:!$,icon:L0,text:z9.text,value:z9.value})]}),E9(d.Menu,{icon:F1,label:"Row actions",onSelect:(M)=>{if(M===F9.value){Z();return}Q(M)},children:[_N.map(({text:M,value:D})=>Q1(d.MenuItem,{icon:L2,text:M,value:D},D)),Q1(d.MenuDivider,{}),Q1(d.MenuItem,{disabled:!Y,icon:L0,text:F9.text,value:F9.value})]}),Q1(d.Divider,{}),Q1(d.Menu,{icon:W1,label:"Table actions",onSelect:()=>J(),children:Q1(d.MenuItem,{icon:L0,text:MJ.text,value:MJ.value})})]})}import{useEffect as DJ,useEffectEvent as UJ,useLayoutEffect as GJ,useMemo as HN,useRef as W9,useState as VJ}from"react";function k6($,Y){if(!$||$.kind==="task-toggle")return null;if($.commentThreadIndex!==null){let X=Y[$.commentThreadIndex]??null;if(!X)return null;return{kind:"comment",left:$.anchorLeft,link:$.kind==="link"?{title:$.title,url:$.url}:null,thread:X,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 zN=600,FN=530,m2=24;function AJ({canShowInsertionLeaf:$,canShowTableLeaf:Y,commentState:X,editorState:Z,editorViewportState:J,getScrollTop:K,layoutWidth:Q,onVisibilityChange:M,resources:D,scrollContentHeight:q,scrollTo:U,viewportHeight:V}){let G=HN(()=>Y0(Z),[Z]),[N,A]=VJ(null),[_,z]=VJ(null),F=G.start.regionId===G.end.regionId&&G.start.offset===G.end.offset,B=W9(!0),W=W9(0),S=W9(null),b=UJ(()=>{M()}),k=UJ(()=>{W.current=typeof performance<"u"?performance.now():Date.now(),B.current=!0,b()});return GJ(()=>{let P=EN({canShowInsertionLeaf:$,canShowTableLeaf:Y,commentState:X,normalizedSelection:G,state:Z,viewport:J.get()});A((y)=>TN(y,P)?y:P)},[$,Y,X,Z,J]),GJ(()=>{let P=D?wN(Z,J.get(),G,D):null;z((y)=>ON(y,P)?y:P)},[Z,J,G,D]),DJ(()=>{let P=Z.selection.focus,y={layoutWidth:Q,offset:P.offset,regionId:P.regionId,scrollContentHeight:q,viewportHeight:V};if(jN(S.current,y))return;let E=x3(Z,J.get(),P);if(!E)return;let w=K(),C=w+m2,T=w+V-m2;if(E.top<C){let H=U(Math.max(0,E.top-m2));if(NJ(E,H,V,m2))S.current=y;return}if(E.top+E.height>T){let H=U(Math.max(0,E.top+E.height-V+m2));if(NJ(E,H,V,m2))S.current=y;return}S.current=y},[Z,Z.selection.focus.offset,Z.selection.focus.regionId,J,Q,q,U,V]),DJ(()=>{if(B.current=!0,b(),!F||typeof window>"u")return;let P=window.setInterval(()=>{if((typeof performance<"u"?performance.now():Date.now())-W.current<zN){if(!B.current)B.current=!0,b();return}B.current=!B.current,b()},FN);return()=>{window.clearInterval(P)}},[F]),{imageAtCursor:_,leaf:N,isVisible:()=>B.current,markActivity:k}}function EN({canShowInsertionLeaf:$,canShowTableLeaf:Y,commentState:X,normalizedSelection:Z,state:J,viewport:K}){if(!K)return null;let Q=J.selection.focus;if(Z.start.regionId!==Z.end.regionId||Z.start.offset!==Z.end.offset)return null;let M=$?yN(J,K):null;if(M)return M;let D=Y?WN(J,K):null;if(D)return D;return k6(p3(J,K,Q,X.liveRanges),X.threads)}function WN($,Y){let X=$.selection.focus,Z=$.documentIndex.regionIndex.get(X.regionId),J=Z?$.documentIndex.tableCellIndex.get(Z.id)??null:null;if(!Z||!J)return null;let K=$.documentIndex.blockIndex.get(Z.blockId),Q=K?.type==="table"?$.documentIndex.document.blocks[K.rootIndex]:null;if(!K||!Q||Q.type!=="table")return null;let M=J1($,Y,X),D=PN(Y,Z.id),q=Math.max(1,...Q.rows.map((U)=>U.cells.length));return M&&D!==null?{cellIndex:J.cellIndex,columnCount:q,kind:"table",left:D,rowCount:Q.rows.length,rowIndex:J.rowIndex,top:M.top+M.height}:null}function PN($,Y){let X=$.layout.lines.find((Z)=>Z.regionId===Y);return X?X.left:null}function yN($,Y){let X=$.selection.focus,Z=$.documentIndex.regionIndex.get(X.regionId);if(!Z||Z.blockType!=="paragraph"||Z.text.length>0)return null;if(X.offset!==0)return null;let J=$.documentIndex.blockIndex.get(Z.blockId);if(!J||J.parentBlockId!==null)return null;let K=J1($,Y,X);return K?{kind:"insertion",left:K.left,top:K.top+K.height}:null}function TN($,Y){if($===Y)return!0;if(!$||!Y||$.kind!==Y.kind)return!1;switch($.kind){case"comment":return Y.kind==="comment"&&$.left===Y.left&&$.link?.title===Y.link?.title&&$.link?.url===Y.link?.url&&$.thread===Y.thread&&$.threadIndex===Y.threadIndex&&$.top===Y.top;case"insertion":return Y.kind==="insertion"&&$.left===Y.left&&$.top===Y.top;case"link":return Y.kind==="link"&&$.endOffset===Y.endOffset&&$.left===Y.left&&$.regionId===Y.regionId&&$.startOffset===Y.startOffset&&$.title===Y.title&&$.top===Y.top&&$.url===Y.url;case"table":return Y.kind==="table"&&$.cellIndex===Y.cellIndex&&$.columnCount===Y.columnCount&&$.left===Y.left&&$.rowCount===Y.rowCount&&$.rowIndex===Y.rowIndex&&$.top===Y.top}}function jN($,Y){return $?.layoutWidth===Y.layoutWidth&&$.regionId===Y.regionId&&$.offset===Y.offset&&$.scrollContentHeight===Y.scrollContentHeight&&$.viewportHeight===Y.viewportHeight}function NJ($,Y,X,Z){return $.top>=Y+Z&&$.top+$.height<=Y+X-Z}function wN($,Y,X,Z){if(!Y)return null;if(X.start.regionId!==X.end.regionId||X.start.offset!==X.end.offset)return null;let J=R5($);if(!J)return null;let K=j4($,Y,Z,J),Q=J.image?Z.images.get(J.image.url)?.intrinsicWidth??null:null,M=$.selection.anchor.regionId;return K?{bounds:K,maxWidth:Q,regionId:M,run:J}:null}function ON($,Y){if($===Y)return!0;if(!$||!Y)return!1;return $.regionId===Y.regionId&&$.maxWidth===Y.maxWidth&&$.bounds.left===Y.bounds.left&&$.bounds.top===Y.bounds.top&&$.bounds.width===Y.bounds.width&&$.bounds.height===Y.bounds.height}import{useMemo as P9,useRef as X5,useEffectEvent as y9}from"react";var BN=48;function _J($,Y,X){let Z=X5(null),J=X5(null),K=X5(null),Q=X5(null),M=X5(1),D=y9((N,A)=>{if(!$)return;N.preventDefault(),N.stopPropagation(),N.currentTarget.setPointerCapture(N.pointerId),Q.current=N.pointerId,Z.current=N.clientX,J.current=N.clientY,K.current=$.run.image?.width??$.bounds.width,M.current=A}),q=y9((N)=>{if(Q.current!==N.pointerId||Z.current===null||J.current===null||K.current===null||!$?.run.image)return;let A=N.clientX-Z.current,_=N.clientY-J.current,z=Math.min($.maxWidth??1/0,Math.max(BN,Math.round(K.current+M.current*(A+_)))),F=r$(Y,$.regionId,$.run,z);if(F)X(F)}),U=y9((N)=>{if(N.currentTarget.hasPointerCapture(N.pointerId))N.currentTarget.releasePointerCapture(N.pointerId);Q.current=null,Z.current=null,J.current=null,K.current=null}),V=P9(()=>({onPointerDown:(N)=>D(N,-1),onPointerMove:q,onPointerUp:U,onPointerCancel:U}),[]),G=P9(()=>({onPointerDown:(N)=>D(N,1),onPointerMove:q,onPointerUp:U,onPointerCancel:U}),[]);return P9(()=>{if(!$)return null;let{bounds:N}=$;return{start:{left:N.left,top:N.top,props:V},end:{left:N.left+N.width,top:N.top+N.height,props:G}}},[$])}import{useEffect as HJ,useEffectEvent as zJ,useMemo as FJ,useRef as CN,useState as LN}from"react";function EJ($,Y){let[X,Z]=LN(new Map),J=zJ((D)=>{if(typeof Image>"u")return;let q=[...X.keys()].filter((U)=>!D.has(U));if(q.length>0)Z((U)=>{let V=new Map(U);for(let G of q)V.delete(G);return V});for(let U of D){let V=X.get(U)?.status;if(V==="loaded"||V==="loading")continue;Z((G)=>T9(G,U,Z5("loading"))),RN(U,Y).then((G)=>{Z((N)=>{if(!N.has(U))return G?.close(),N;return T9(N,U,G?Z5("loaded",G):Z5("error"))})})}});HJ(()=>{J($)},[$]);let K=CN(new Map);HJ(()=>{for(let[D,q]of K.current)if(!X.has(D))q.source?.close();K.current=X},[X]);let Q=zJ(async(D)=>{if(!Y?.writeFile)return null;try{let q=await Y.writeFile(D),U=await createImageBitmap(D).catch(()=>null);return Z((V)=>T9(V,q,U?Z5("loaded",U):Z5("error"))),q}catch{return null}}),M=FJ(()=>X.size===0?null:{images:X},[X]);return FJ(()=>({resources:M,persistImage:Q}),[M,Q])}async function RN($,Y){if(/^(https?:|data:|blob:)/i.test($))return bN($);if(!Y?.readFile)return null;try{let X=await Y.readFile($);return X?await createImageBitmap(X):null}catch{return null}}function bN($){return new Promise((Y)=>{let X=new Image;X.decoding="async",X.crossOrigin="anonymous",X.onload=async()=>{try{Y(await createImageBitmap(X))}catch{Y(null)}},X.onerror=()=>Y(null),X.src=$})}function T9($,Y,X){let Z=new Map($);return Z.set(Y,X),Z}function Z5($,Y){return{intrinsicHeight:Y?.height??0,intrinsicWidth:Y?.width??0,source:Y??null,status:$}}import{useEffect as WJ,useEffectEvent as F0,useRef as J5,useState as SN}from"react";var vN=48;function PJ({applyNextState:$,autoScrollDuringDrag:Y,canvasRef:X,commentState:Z,editorStateRef:J,editorViewportState:K,focusInput:Q,onActivity:M,readCurrentState:D,resolvePoint:q}){let[U,V]=SN(null),G=J5(null),N=J5(!1),A=J5(null),_=J5(null),z=J5(null),F=k6(U,Z.threads),B=U?.kind==="task-toggle"||F?.kind==="link"?"pointer":"text";WJ(()=>{if(U&&U.kind!=="task-toggle"&&!F)V(null)},[U,F]),WJ(()=>()=>{if(G.current!==null)window.clearTimeout(G.current)},[]);let W=F0(()=>{if(G.current!==null)window.clearTimeout(G.current),G.current=null}),S=F0(()=>{W(),G.current=window.setTimeout(()=>{if(G.current=null,!N.current)V(null)},vN)}),b=F0(()=>{if(!N.current)W(),V(null)}),k=F0((j)=>{if(!j){b();return}if(j.kind==="task-toggle"){W(),V((O)=>O?.kind==="task-toggle"&&O.listItemId===j.listItemId?O:j);return}if(j.commentThreadIndex!==null){if(!(Z.threads[j.commentThreadIndex]??null)){b();return}W();let v=j.commentThreadIndex;V((f)=>f?.kind!=="task-toggle"&&f?.commentThreadIndex===v?f:j);return}if(j.kind!=="link"){b();return}W(),V((O)=>O?.kind==="link"&&O.title===j.title&&O.url===j.url&&O.startOffset===j.startOffset&&O.endOffset===j.endOffset?O:j)}),P=F0((j)=>{let O=J.current;if(!O)return null;let v=q(j);if(!v)return null;return I3(O,K.get(),v,Z.liveRanges)}),y=F0((j)=>{let O=X.current;if(O&&A.current===j)O.releasePointerCapture(j)}),E=F0(()=>{A.current=null,_.current=null}),w=F0((j)=>{y(j.pointerId),E()}),C=F0((j)=>{if(z.current=j.pointerType,j.pointerType==="touch")return;let O=X.current,v=D(),f=q(j);if(!f)return;if(P(j)?.kind==="task-toggle")return;let x=F6(v,K.get(),f);if(!O||!x)return;if(A.current=j.pointerId,M(),O.setPointerCapture(j.pointerId),j.shiftKey)_.current=v.selection.anchor,$(p$(v,x.regionId,x.offset));else _.current={offset:x.offset,regionId:x.regionId},$(K0(v,{offset:x.offset,regionId:x.regionId}));Q({offset:x.offset,regionId:x.regionId})}),T=F0((j)=>{let O=_.current,v=D(),f=q(j);if(!f)return;if(A.current!==j.pointerId||!O){k(P(j));return}let a=w4(v,K.get(),f,O);if(!a)return;M(),Y(j),$(K0(v,{anchor:O,focus:a}))}),H=F0(()=>{if(!N.current)S()}),R=F0((j)=>{let O=z.current==="touch";z.current=null;let v=P(j);if(v?.kind==="task-toggle"){let E0=D(),t0=t$(E0,v.listItemId);if(t0)j.preventDefault(),j.stopPropagation(),M(),$(t0);return}if(v?.kind==="link"&&(j.metaKey||j.ctrlKey)){j.preventDefault(),j.stopPropagation(),j.currentTarget.ownerDocument.defaultView?.open(v.url,"_blank","noopener,noreferrer");return}if(!O){Q();return}let f=D(),a=q(j),x=a?F6(f,K.get(),a):null;if(x)M(),$(K0(f,{offset:x.offset,regionId:x.regionId})),Q({offset:x.offset,regionId:x.regionId});else Q()}),u=F0((j)=>{let O=D(),v=q(j),f=P(j);if(!v||f?.kind==="task-toggle")return;let a=g3(O,K.get(),v);if(!a)return;j.preventDefault(),j.stopPropagation(),M(),$(K0(O,a)),Q()}),g=F0(()=>{N.current=!0,W()}),I=F0(()=>{N.current=!1,S()});return{canvasHandlers:{onClick:R,onDoubleClick:u,onPointerCancel:w,onPointerDown:C,onPointerLeave:H,onPointerMove:T,onPointerUp:w},cursor:B,leaf:F,leafHandlers:{onPointerEnter:g,onPointerLeave:I}}}import{useEffect as w9,useEffectEvent as N0,useLayoutEffect as fN,useRef as TJ,useState as mN}from"react";import{useEffect as Sv1}from"react";var j9=[{key:"Backspace",command:"deleteBackward"},{key:"Enter",shiftKey:!0,command:"insertSoftLineBreak"},{key:"Enter",command:"insertLineBreak"},{key:"Home",command:"moveToLineStart"},{key:"End",command:"moveToLineEnd"},{key:"Tab",command:"indent"},{key:"Tab",shiftKey:!0,command:"dedent"},{key:"ArrowLeft",modKey:!0,shiftKey:"any",command:"moveToLineStart"},{key:"ArrowRight",modKey:!0,shiftKey:"any",command:"moveToLineEnd"},{key:"ArrowUp",modKey:!0,shiftKey:"any",command:"moveToDocumentStart"},{key:"ArrowDown",modKey:!0,shiftKey:"any",command:"moveToDocumentEnd"},{key:"ArrowUp",altKey:!0,shiftKey:!0,command:"moveListItemUp"},{key:"ArrowDown",altKey:!0,shiftKey:!0,command:"moveListItemDown"},{key:"a",modKey:!0,command:"selectAll"},{key:"b",modKey:!0,command:"toggleBold"},{key:"e",modKey:!0,command:"toggleCode"},{key:"i",modKey:!0,command:"toggleItalic"},{key:"u",modKey:!0,command:"toggleUnderline"},{key:"y",modKey:!0,command:"redo"},{key:"z",modKey:!0,command:"undo"},{key:"z",modKey:!0,shiftKey:!0,command:"redo"}];function yJ($,Y=j9){return Y.find((X)=>{let Z=X.shiftKey==="any"?!0:(X.shiftKey??!1)===($.shiftKey??!1);return X.key.toLowerCase()===$.key.toLowerCase()&&(X.altKey??!1)===($.altKey??!1)&&Z&&(X.modKey??!1)===Boolean($.metaKey||$.ctrlKey)})?.command??null}var hN=1024,jJ=16;function BJ({applyNextState:$,editorState:Y,editorStateRef:X,editorViewportState:Z,inputRef:J,keybindings:K,onActivity:Q,onImagePaste:M}){let D=kN(),q=()=>X.current??Y,U=TJ(!1),V=TJ(!1),G=N0((H)=>{if(!H)return;Q(),$(H)}),N=N0(()=>{let H=J.current;if(!H)return;if(typeof document>"u")return;let R=document.execCommand;if(typeof R!=="function")return;try{U.current=!0,R.call(document,"insertText",!1,""),R.call(document,"delete")}catch{}finally{U.current=!1,K5(H,q())}}),A=N0(()=>{if(V.current)return;V.current=!0,N()}),_=N0(()=>{N()}),z=N0((H)=>{if(!D)return;let R=J.current;if(!R)return;let u=Z.get(),g=J1(q(),u,H);if(!g)return;R.style.top=`${g.top}px`,R.style.left=`${g.left}px`,R.style.height=`${g.height}px`}),F=N0((H)=>{let R=J.current;if(!R)return;z(H??q().selection.focus),R.focus({preventScroll:!D}),K5(R,q()),A()}),B=N0((H,R)=>{let g=OJ(R,u6(H)).replace(/\r\n/g,`
|
|
34
|
+
`).split(/(\n)/),I=H;for(let j of g){if(j.length===0)continue;let O=j===`
|
|
35
|
+
`?a5(I):N4(I,j);if(!O)continue;I=O}return I===H?null:I}),W=N0((H,R,u)=>{let g=H.selection.focus,I={regionId:g.regionId,offset:Math.max(0,g.offset-R)},j=K0(H,{anchor:I,focus:g});return r5(j,u)}),S=N0((H)=>{if(U.current)return;let R=q(),u=IN(H.inputType);if(H.inputType==="insertText"){if(!H.data)return;H.preventDefault();let g=wJ(H.target);if(g>0){G(W(R,g,H.data));return}let I=gN(R,H.data);if(I>0){let j=H.data.slice(I);if(j.length>0)G(B(R,j));return}G(B(R,H.data));return}if(H.inputType==="insertReplacementText"){if(!H.data)return;H.preventDefault();let g=wJ(H.target);G(W(R,g,H.data));return}if(uN(H.inputType)){H.preventDefault(),G(a5(R));return}if(u==="backward"){H.preventDefault(),G(G3(R));return}if(u==="forward"){H.preventDefault(),G(V3(R));return}if(H.inputType==="historyUndo"){H.preventDefault(),G(A3(R)),_();return}if(H.inputType==="historyRedo"){H.preventDefault(),G(_3(R)),_();return}}),b=N0((H)=>{let R=q(),u=H.currentTarget.value,g=u6(R);if(U.current)return;if(OJ(u,g).length===0){K5(H.currentTarget,R);return}G(B(R,u))}),k=N0((H)=>{let R=xN(q(),Z.get(),H.nativeEvent,K);if(!R)return;H.preventDefault(),G(R)}),P=N0((H)=>{let R=N3(q());if(!R)return;H.preventDefault(),H.clipboardData.setData("text/plain",f6(R))}),y=N0((H)=>{let R=q(),u=N3(R);if(!u)return;H.preventDefault(),H.clipboardData.setData("text/plain",f6(u)),G(U3(R))}),E=N0(async(H)=>{let u=(M?[...H.clipboardData.items].find((j)=>j.kind==="file"&&j.type.startsWith("image/")):void 0)?.getAsFile()??null;if(u&&M){H.preventDefault();let j=await M(u);if(j)G(a$(q(),j));return}let g=H.clipboardData.getData("text/plain");if(g.length===0)return;H.preventDefault();let I=K9(g);G(I$(q(),I,g))}),w=N0(()=>{Q();let H=J.current;if(H)K5(H,q())}),C=N0((H)=>{if(Q(),H.target.matches(":focus-visible"))F()});w9(()=>{let H=J.current;if(!H)return;K5(H,Y)},[Y,J]),fN(()=>{z(Y.selection.focus)},[Y,z]),w9(()=>{let H=J.current;if(!H)return;let R=(u)=>S(u);return H.addEventListener("beforeinput",R),()=>H.removeEventListener("beforeinput",R)},[J,S]);let T={onCopy:P,onCut:y,onPaste:E,...D?{}:{onKeyDown:k}};return{canvasHandlers:{...T,onFocus:C},focus:F,inputHandlers:{...T,onFocus:w,onInput:b}}}var CJ="";function kN(){let[$,Y]=mN(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(pointer: coarse)").matches});return w9(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function")return;let X=window.matchMedia("(pointer: coarse)"),Z=(J)=>Y(J.matches);return X.addEventListener?.("change",Z),()=>X.removeEventListener?.("change",Z)},[]),$}function uN($){return $==="insertLineBreak"||$==="insertParagraph"}function wJ($){let Y=$,X=Y?.selectionStart??0,Z=Y?.selectionEnd??X;return Math.max(0,Z-X)}function gN($,Y){if(Y.length<jJ)return 0;let X=u6($,Y.length),Z=Math.min(X.length,Y.length);for(let J=Z;J>=jJ;J--)if(X.endsWith(Y.slice(0,J)))return J;return 0}function IN($){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 pN($){return $.replaceAll(CJ,"")}function u6($,Y=hN){let{anchor:X,focus:Z}=$.selection;if(X.regionId!==Z.regionId||X.offset!==Z.offset)return"";let J=$.documentIndex.regionIndex.get(Z.regionId);if(!J)return"";return J.text.slice(Math.max(0,Z.offset-Y),Z.offset)}function OJ($,Y){let X=pN($);return X.startsWith(Y)?X.slice(Y.length):X}function K5($,Y){let X=u6(Y),Z=`${CJ}${X}`;$.value=Z,$.setSelectionRange(Z.length,Z.length)}function xN($,Y,X,Z){if(X.key==="Delete")return V3($);let J=yJ(X,Z);if(J){if(J==="moveToLineStart"||J==="moveToLineEnd")return a3($,Y.layout,J==="moveToLineStart"?"Home":"End",X.shiftKey);if(J==="moveToDocumentStart"||J==="moveToDocumentEnd")return r3($,J==="moveToDocumentStart"?"start":"end",X.shiftKey);switch(J){case"insertLineBreak":return a5($);case"insertSoftLineBreak":return g$($);case"deleteBackward":return G3($);case"indent":return s$($);case"dedent":return i$($);case"moveListItemUp":return o$($);case"moveListItemDown":return n$($);case"toggleBold":return s5($);case"toggleItalic":return i5($);case"toggleStrikethrough":return o5($);case"toggleUnderline":return n5($);case"toggleCode":return l$($);case"undo":return A3($);case"redo":return _3($);case"selectAll":return x$($)}}if(X.key==="ArrowLeft"||X.key==="ArrowRight")return l3($,X.key==="ArrowLeft"?-1:1,X.shiftKey);if(X.key==="ArrowUp"||X.key==="ArrowDown")return d3($,Y.layout,X.key==="ArrowUp"?-1:1,X.shiftKey);if(X.key==="PageUp"||X.key==="PageDown")return c3($,Y.layout,X.key==="PageUp"?-1:1,X.shiftKey);if(X.key.length===1&&!X.altKey&&!X.ctrlKey&&!X.metaKey)return N4($,X.key);return null}import{useEffectEvent as O9,useLayoutEffect as lN,useMemo as dN,useState as cN}from"react";function LJ({editorState:$,editorStateRef:Y,editorViewportState:X,onViewportScroll:Z,scrollContainerRef:J,scheduleOverlayRender:K,userPresence:Q}){let M=dN(()=>{if(!Q||Q.length===0)return;return j5($.documentIndex,Q)},[$.documentIndex,Q]),[D,q]=cN(void 0),U=O9(()=>{if(M===void 0){if(D!==void 0)q(void 0)}else q(d2(Y.current??$,X.get(),M));K()}),V=O9((N)=>{if(M===void 0){if(D!==void 0)q(void 0);return}let A=d2(Y.current??$,N,M);if(aN(D,A))return;q(A)});lN(()=>{U()},[M]);let G=O9((N)=>{if(!N.viewport||N.viewport.status==="unresolved")return;let A=J.current;if(!A)return;A.scrollTop=N.viewport.scrollTop,Z(A)});return{presence:D,scrollToPresence:G,refreshPresence:V}}function aN($,Y){if($===Y)return!0;if($===void 0||Y===void 0||$.length!==Y.length)return!1;return $.every((X,Z)=>{let J=Y[Z];return X.id===J.id&&rN(X.viewport,J.viewport)})}function rN($,Y){if($===Y)return!0;if($===null||Y===null)return!1;if($.status==="unresolved")return Y.status==="unresolved";if(Y.status==="unresolved")return!1;return $.status===Y.status&&$.scrollTop===Y.scrollTop}import{useEffect as sN,useEffectEvent as a1,useRef as Q5}from"react";function RJ({editorStateRef:$,renderContent:Y,renderOverlay:X,renderViewport:Z}){let J=Q5(null),K=Q5(!1),Q=Q5(!1),M=Q5(!1),D=Q5(!1),q=a1(()=>{if(typeof window>"u"){Z();return}K.current=!0,N()}),U=a1(()=>{if(typeof window>"u"){Y(),X();return}Q.current=!0,N()}),V=a1(()=>{if(typeof window>"u"){Y();return}M.current=!0,N()}),G=a1(()=>{if(typeof window>"u"){X();return}D.current=!0,N()}),N=a1(()=>{if(typeof window>"u"||J.current!==null)return;J.current=window.requestAnimationFrame(()=>{A()})}),A=a1(()=>{J.current=null;let z=K.current,F=Q.current,B=M.current,W=D.current;if(K.current=!1,Q.current=!1,M.current=!1,D.current=!1,z){Z(),_();return}if(F){Y(),X(),_();return}if(B)Y(),_();if(W)X()}),_=a1(()=>{let z=$.current;if(!z||!p8(z,performance.now()))return;M.current=!0,N()});return sN(()=>{return()=>{if(typeof window>"u"||J.current===null)return;window.cancelAnimationFrame(J.current),J.current=null}},[]),{scheduleContentPaint:V,scheduleFullPaint:U,scheduleFullRender:q,scheduleOverlayPaint:G}}import{useEffectEvent as B9,useLayoutEffect as kJ,useMemo as C9,useRef as L9,useState as uJ}from"react";function fJ($){let Y=$.documentIndex.regions.find((K)=>K.id===$.selection.anchor.regionId),X=$.documentIndex.regions.find((K)=>K.id===$.selection.focus.regionId),Z=(Y?.start??0)+$.selection.anchor.offset,J=(X?.start??0)+$.selection.focus.offset;return{end:Math.max(Z,J),start:Math.min(Z,J)}}function mJ($){let Y=iN($);if(Y.start.regionId!==Y.end.regionId||Y.start.offset===Y.end.offset)return null;return{endOffset:Y.end.offset,regionId:Y.start.regionId,startOffset:Y.start.offset}}var bJ=28,SJ=18;function hJ($,Y){if(!$)return;let X=$.getBoundingClientRect();if(Y.clientY<X.top+bJ){$.scrollTop=Math.max(0,$.scrollTop-SJ);return}if(Y.clientY>X.bottom-bJ)$.scrollTop+=SJ}function iN($){let Y=vJ($.documentIndex.regions,$.selection.anchor.regionId,$.selection.anchor.offset),X=vJ($.documentIndex.regions,$.selection.focus.regionId,$.selection.focus.offset);return Y<=X?{end:$.selection.focus,start:$.selection.anchor}:{end:$.selection.anchor,start:$.selection.focus}}function vJ($,Y,X){let Z=$.findIndex((J)=>J.id===Y);if(Z===-1)return-1;return Z*1e6+X}function gJ({applyNextState:$,autoScrollDuringDrag:Y,canShowSelectionLeaf:X,editorState:Z,editorStateRef:J,editorViewportState:K,focusInput:Q,onActivity:M,resolvePoint:D,threads:q}){let U=C9(()=>Y0(Z),[Z]),V=C9(()=>mJ(Z),[Z]),G=C9(()=>b5(Z),[Z]),[N,A]=uJ(null),[_,z]=uJ(null),F=L9(null),B=L9(null),W=L9(null);kJ(()=>{let E=oN(Z,K.get(),U);A((w)=>YA(w,E)?w:E)},[Z,K,U.end.offset,U.end.regionId,U.start.offset,U.start.regionId]),kJ(()=>{let E=tN({canShowSelectionLeaf:X,currentLeaf:_,activeMarks:G,handles:N,selectionRange:V,threads:q});z((w)=>$A(w,E)?w:E)},[G,X,N,_,V,q]);let S=B9((E,w=!0)=>{z((C)=>C?.kind==="create"?{animateInitialComment:w,kind:"thread",left:C.left,threadIndex:E,top:C.top}:C)}),b=B9((E)=>{if(E&&W.current===E.pointerId&&E.currentTarget.hasPointerCapture(E.pointerId))E.currentTarget.releasePointerCapture(E.pointerId);F.current=null,B.current=null,W.current=null}),k=B9((E)=>{let w=J.current,C=B.current,T=D(E);if(!T||!w||!C||W.current!==E.pointerId)return;let H=w4(w,K.get(),T,C);if(!H)return;E.preventDefault(),E.stopPropagation(),M(),Y(E),$(K0(w,{anchor:C,focus:H}))}),P=(E)=>({onPointerCancel:(w)=>{b(w)},onPointerDown:(w)=>{let C=J.current??Z,T=ZA(U,E),H=E==="start"?U.start:U.end;if(!N)return;w.preventDefault(),w.stopPropagation(),W.current=w.pointerId,B.current=T,F.current=E,w.currentTarget.setPointerCapture(w.pointerId),M(),Q(),$(K0(C,{anchor:T,focus:H}))},onPointerMove:(w)=>{if(F.current!==E)return;k(w)},onPointerUp:(w)=>{if(F.current===E)k(w);b(w)}});return{handle:N?{start:{...N.start,props:P("start")},end:{...N.end,props:P("end")}}:null,leaf:_,promoteLeafToThread:S}}function oN($,Y,X){if(X.collapsed)return null;let Z=J1($,Y,X.start),J=J1($,Y,X.end);if(!Z||!J)return null;return{end:{left:J.left,top:J.top+J.height},start:{left:Z.left,top:Z.top}}}function nN($,Y,X){return{activeMarks:X,kind:"create",left:Y.start.left,selection:$,top:Y.end.top}}function tN({activeMarks:$,canShowSelectionLeaf:Y,currentLeaf:X,handles:Z,selectionRange:J,threads:K}){if(!Y||!J||!Z)return null;if(X?.kind==="thread")return K[X.threadIndex]?X:null;return nN(J,Z,$)}function eN($,Y){return $?.kind==="create"&&$.left===Y.left&&$.selection.regionId===Y.selection.regionId&&$.selection.startOffset===Y.selection.startOffset&&$.selection.endOffset===Y.selection.endOffset&&XA($.activeMarks,Y.activeMarks)&&$.top===Y.top}function $A($,Y){if($===Y)return!0;if(!$||!Y||$.kind!==Y.kind)return!1;if($.kind==="create"&&Y.kind==="create")return eN($,Y);return $.kind==="thread"&&Y.kind==="thread"&&$.animateInitialComment===Y.animateInitialComment&&$.left===Y.left&&$.threadIndex===Y.threadIndex&&$.top===Y.top}function YA($,Y){if($===Y)return!0;if(!$||!Y)return!1;return $.start.left===Y.start.left&&$.start.top===Y.start.top&&$.end.left===Y.end.left&&$.end.top===Y.end.top}function XA($,Y){return $.length===Y.length&&$.every((X,Z)=>X===Y[Z])}function ZA($,Y){return Y==="start"?$.end:$.start}import{useEffect as JA,useMemo as xJ,useState as KA}from"react";var M5={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)"},q5={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)"},IJ={...M5,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)"},pJ={...q5,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 lJ($){let Y=xJ(()=>MA($),[$]),[X,Z]=KA(Y.light),J=xJ(()=>qA(X),[X]);return JA(()=>{if(typeof window>"u"||typeof window.matchMedia!=="function"){Z(Y.light);return}let K=window.matchMedia("(prefers-color-scheme: dark)"),Q=()=>{Z(K.matches?Y.dark:Y.light)};if(Q(),typeof K.addEventListener==="function")return K.addEventListener("change",Q),()=>{K.removeEventListener("change",Q)};return K.addListener(Q),()=>{K.removeListener(Q)}},[Y]),{theme:X,themeStyles:J}}function QA($){return"light"in $&&"dark"in $}function MA($){if(!$)return{dark:q5,light:M5};if(QA($))return $;return{dark:$,light:$}}function qA($){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 GA,useEffectEvent as n0,useRef as R9,useState as g6}from"react";import{useMemo as DA}from"react";function dJ($){return DA(()=>UA({current:null},$),[$])}function UA($,Y){return{peek(){return $.current},get(){let X=$.current;if(X!==null)return X;let Z=Y();return $.current=Z,Z},invalidate(){$.current=null}}}function cJ($,Y){let X=Y.getBoundingClientRect();return{x:$.clientX-X.left+Y.scrollLeft,y:$.clientY-X.top+Y.scrollTop}}function aJ({editorState:$,editorStateRef:Y,renderResources:X,theme:Z}){let J=R9(k1()),K=R9(null),Q=R9({height:240,top:0}),[M,D]=g6(0),[q,U]=g6(240),[V,G]=g6(0),[N,A]=g6(240),_=VA(M),z=n0(()=>{let T=Y.current??$,H=Q.current;return u3(T,{height:H.height,paddingX:Z.paddingX,paddingY:Z.paddingY,top:H.top,width:_},J.current,X)}),F=dJ(z),B=n0((T)=>{A((H)=>{let R=AA(T,Q.current.height);return H===R?H:R})}),W=n0((T)=>{Q.current={...Q.current,top:T},G((H)=>H===T?H:T),F.invalidate()}),S=n0((T)=>{let H=NA(T),R=H.top!==Q.current.top;if(Q.current=H,G((u)=>u===H.top?u:H.top),R)F.invalidate()}),b=n0((T)=>{let H=K.current;if(!H)return W(T),T;H.scrollTop=T;let R=H.scrollTop;return W(R),R}),k=n0(()=>{return K.current?.scrollTop??Q.current.top}),P=n0((T,H)=>{let R=T!==null&&T.documentIndex!==H.documentIndex,u=F.peek();if(!(!R||!u||u.layout.regionLineIndices.has(H.selection.focus.regionId)))F.invalidate()}),y=n0(()=>{return F.invalidate(),F.get()}),E=n0((T)=>{let H=K.current;return H?cJ(T,H):null}),w=n0((T)=>{hJ(K.current,T)});return GA(()=>{let T=K.current;if(!T||typeof ResizeObserver>"u")return;let H=new ResizeObserver((R)=>{let u=R[0];if(!u)return;let g=Math.max(0,Math.floor(u.contentRect.width)),I=rJ(T);Q.current={...Q.current,height:I},D((j)=>j===g?j:g),U((j)=>j===I?j:I)});return H.observe(T),()=>H.disconnect()},[K]),{actions:{autoScrollDuringDrag:w,getScrollTop:k,observePreparedViewport:B,observeScrollContainer:S,prepareNextPaint:y,reconcileEditorState:P,resolvePoint:E,scrollTo:b},props:{getScrollContainer:(T)=>({onScroll:(H)=>{S(H.currentTarget),T?.onScroll?.(H)},ref:K}),scrollContent:{style:{height:`${N}px`}}},refs:{scrollContainer:K},state:{layoutWidth:_,preparedViewport:F,scrollContentHeight:N,surfaceWidth:M,viewportHeight:q,viewportTop:V}}}function VA($){return Math.max(240,Math.floor($||480))}function rJ($){return Math.max(240,$.clientHeight)}function NA($){return{height:rJ($),top:$.scrollTop}}function AA($,Y){return Math.max(Y,Math.ceil($.totalHeight+24))}function _A(){if(typeof window>"u")return 1;return Math.max(1,window.devicePixelRatio||1)}function b9($,{paintHeight:Y,paintTop:X,width:Z}){if(!$)return null;let J=Math.max(240,Math.ceil(Y)),K=_A();$.width=Math.ceil(Z*K),$.height=Math.ceil(J*K),$.style.width=`${Z}px`,$.style.height=`${J}px`,$.style.transform=`translateY(${X}px)`;let Q=$.getContext("2d");if(!Q)return null;return{context:Q,devicePixelRatio:K,height:J,width:Z}}function S9($,Y){return $.activeBlockType===Y.activeBlockType&&$.activeCommentThreadIndex===Y.activeCommentThreadIndex&&$.activeSpanKind===Y.activeSpanKind&&$.canonicalContent===Y.canonicalContent&&$.characterCount===Y.characterCount&&$.commentThreadCount===Y.commentThreadCount&&$.layoutWidth===Y.layoutWidth&&$.resolvedCommentCount===Y.resolvedCommentCount&&$.selectionFrom===Y.selectionFrom&&$.selectionTo===Y.selectionTo}function sJ($,Y){if(!Y?.length||!$?.length)return;let X=new Map($.map((J)=>[J.id,J])),Z=[];for(let J of Y){let K=X.get(J.userId);if(!K)continue;Z.push({...K,color:J.color,cursor:J.cursor})}return Z.length===0?void 0:Z}function oJ($,Y){if(!$)return{didReconcile:!1,state:Y};let X=HA($,Y)??wA($,Y);return X?{didReconcile:!0,state:X}:{didReconcile:!1,state:Y}}function HA($,Y){let X=zA($,Y);return X?K0(Y,X,!1):null}function zA($,Y){if(m9($.selection.anchor,$.selection.focus)){let K=v9($,Y,$.selection.focus,"neutral");return K?{anchor:K,focus:K}:null}let X=TA($),Z=v9($,Y,$.selection.anchor,X.anchor),J=v9($,Y,$.selection.focus,X.focus);return Z&&J?{anchor:Z,focus:J}:null}function v9($,Y,X,Z){let J=$.documentIndex.regionIndex.get(X.regionId);if(!J)return null;let K=f9(J,Y);if(!K)return null;return{offset:EA(J.text,K.text,X.offset,Z),regionId:K.id}}function f9($,Y){let X=Y.documentIndex.regionIndex.get($.id);if(X)return X;if($.text.length===0)return null;let Z=FA($,Y);if(Z)return Z;return Y.documentIndex.regionPathIndex.get($.path)??null}function FA($,Y){let X=null;for(let Z of Y.documentIndex.regions){if(Z.blockType!==$.blockType||Z.text!==$.text)continue;if(X)return null;X=Z}return X}function EA($,Y,X,Z){let J=b0(X,0,$.length),{prefix:K,suffix:Q}=U8($,J,J),M=WA(Y,K,Q);if(M!==null)return M;let D=PA(Y,K),q=yA(Y,Q);if(Z==="before-suffix")return q??D??b0(X,0,Y.length);return D??q??b0(X,0,Y.length)}function WA($,Y,X){let Z=K2($,Y,X).filter((J)=>J.startOffset===J.endOffset);return Z.length===1?Z[0].startOffset:null}function PA($,Y){let X=a0($,Y);return X.length===1?X[0]+Y.length:null}function yA($,Y){let X=a0($,Y);return X.length===1?X[0]:null}function TA($){let{anchor:Y,focus:X}=$.selection;if(m9(Y,X))return{anchor:"neutral",focus:"neutral"};return jA($,Y,X)<=0?{anchor:"before-suffix",focus:"after-prefix"}:{anchor:"after-prefix",focus:"before-suffix"}}function jA($,Y,X){let Z=$.documentIndex.regionOrderIndex.get(Y.regionId),J=$.documentIndex.regionOrderIndex.get(X.regionId);if(Z===void 0||J===void 0)return 0;return Z===J?Y.offset-X.offset:Z-J}function wA($,Y){if(!m9($.selection.anchor,$.selection.focus))return null;let X=OA($);if(!X)return null;let Z=BA($,Y,X);if(Z===null)return null;return CA(Y,Z)}function OA($){let Y=$.documentIndex.regionIndex.get($.selection.focus.regionId);if(!Y||Y.blockType!=="paragraph"||Y.text.length>0)return null;return $.documentIndex.blockIndex.get(Y.blockId)?.parentBlockId===null?Y:null}function BA($,Y,X){let Z=iJ($,X.rootIndex,"before"),J=iJ($,X.rootIndex,"after"),K=Z?f9(Z,Y):null,Q=J?f9(J,Y):null;if(K&&Q)return K.rootIndex<Q.rootIndex?Q.rootIndex:null;if(K)return K.rootIndex+1;if(Q)return Q.rootIndex;return null}function CA($,Y){let X=L1($.documentIndex.document,Y,0,[i({text:""})]),Z={...$,documentIndex:q2($.documentIndex,X,Y,0)},J=e2(Z.documentIndex,$0(Y));return J?K0(Z,J,!1):null}function iJ($,Y,X){let Z=X==="before"?-1:1;for(let J=Y+Z;J>=0&&J<$.documentIndex.roots.length;J+=Z){let K=LA($,J,X);if(K)return K}return null}function LA($,Y,X){let Z=$.documentIndex.roots[Y]?.regions??[],J=X==="before"?Z.length-1:0,K=X==="before"?-1:1;for(let Q=J;Q>=0&&Q<Z.length;Q+=K){let M=Z[Q];if(M&&M.text.length>0)return M}return null}function m9($,Y){return $.regionId===Y.regionId&&$.offset===Y.offset}import{jsx as c,jsxs as p6,Fragment as kA}from"react/jsx-runtime";function x6({blocks:$}){return c(kA,{children:$.map((Y)=>RA(Y))})}function RA($){switch($.type){case"blockquote":return c("blockquote",{className:"preview-block preview-block-blockquote",children:c(x6,{blocks:$.children})},$.id);case"code":return p6("div",{className:"preview-block preview-block-code",children:[c("div",{className:"preview-rich-header",children:vA($.language,$.meta)}),c("pre",{children:c("code",{children:$.source||" "})})]},$.id);case"heading":{let Y=`h${$.depth}`;return c(Y,{className:"preview-block preview-block-heading",children:I6($.children)},$.id)}case"list":return $.ordered?c("ol",{className:"preview-block preview-block-list",start:$.start??1,children:$.items.map((Y)=>h9(Y))},$.id):c("ul",{className:"preview-block preview-block-list",children:$.items.map((Y)=>h9(Y))},$.id);case"listItem":return h9($);case"paragraph":return c("p",{className:"preview-block preview-block-paragraph",children:I6($.children)},$.id);case"table":return p6("div",{className:"preview-block preview-block-table",children:[c("div",{className:"preview-rich-header",children:fA($.rows.length,$.rows[0]?.cells.length??0,$.align.filter((Y)=>Y!==null).length)}),c("div",{className:"preview-table-scroll",children:c("table",{children:c("tbody",{children:$.rows.map((Y)=>c("tr",{children:Y.cells.map((X)=>c("td",{children:I6(X.children)},X.id))},Y.id))})})})]},$.id);case"divider":return c("hr",{className:"preview-block preview-block-rule"},$.id);case"directive":return c("pre",{className:`preview-block preview-block-directive preview-block-directive-${$.name}`,children:$.body},$.id);case"raw":return c("pre",{className:"preview-block preview-block-unsupported",children:$.source},$.id)}}function h9($){return c("li",{className:"preview-block preview-block-list-item",children:c(x6,{blocks:$.children})},$.id)}function I6($){return $.map((Y)=>{switch(Y.type){case"lineBreak":return c("br",{},Y.id);case"image":return p6("span",{className:"preview-inline preview-inline-image",children:[c("img",{alt:Y.alt??"",src:Y.url,title:Y.title??""}),p6("span",{children:[c("strong",{children:mA(Y.alt)}),c("small",{children:hA(Y.url,Y.title)})]})]},Y.id);case"code":return c("code",{className:"preview-inline preview-inline-code",children:Y.code},Y.id);case"link":return bA(Y);case"text":return c("span",{className:"preview-inline",children:SA(Y.text,Y.marks)},Y.id);case"raw":return c("span",{className:"preview-inline preview-inline-unsupported",children:Y.source},Y.id)}})}function bA($){return c("a",{className:"preview-inline preview-inline-link",href:$.url,children:I6($.children)},$.id)}function SA($,Y){let X=$;for(let Z of Y)switch(Z){case"strikethrough":X=c("del",{children:X});break;case"italic":X=c("em",{children:X});break;case"bold":X=c("strong",{children:X});break;case"underline":X=c("ins",{children:X});break}return X}function vA($,Y){return[$??"plain text",Y].filter(Boolean).join(" • ")}function fA($,Y,X){let Z=X>0?`${X} aligned ${X===1?"column":"columns"}`:"no alignment";return`${$} ${$===1?"row":"rows"} • ${Y} ${Y===1?"column":"columns"} • ${Z}`}function mA($){return $?.trim()?$:"Untitled image"}function hA($,Y){return Y?.trim()?`${Y} • ${$}`:$}var nJ=`/* Base Documint host and SSR-fallback styles. */
|
|
33
36
|
|
|
34
37
|
.documint {
|
|
35
38
|
display: grid;
|
|
@@ -365,7 +368,7 @@ ${M.text}`:M.text}function YK($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
365
368
|
white-space: nowrap;
|
|
366
369
|
}
|
|
367
370
|
}
|
|
368
|
-
`;var
|
|
371
|
+
`;var tJ=`/* Leaf overlay styles, ordered outer → inner:
|
|
369
372
|
1. Anchor — viewport positioning + hover bridge
|
|
370
373
|
2. Shell — bordered container (with state and content variants)
|
|
371
374
|
3. Menu — shared dropdown surface (toolbar menus, completion popover)
|
|
@@ -875,7 +878,7 @@ ${M.text}`:M.text}function YK($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
875
878
|
font-weight: 500;
|
|
876
879
|
white-space: nowrap;
|
|
877
880
|
}
|
|
878
|
-
`;var
|
|
881
|
+
`;var eJ=`/* Toolbar-specific styles (button, group, divider, and the menu trigger
|
|
879
882
|
shell + chevron). The menu container/item/divider styles themselves
|
|
880
883
|
live one level up in \`overlays/leaves/styles.css\` as \`.documint-leaf-menu*\`
|
|
881
884
|
so they can be shared by the toolbar's nested menu and other surfaces
|
|
@@ -957,6 +960,6 @@ ${M.text}`:M.text}function YK($){return $.filter((M)=>M.regions.length>0).map((M
|
|
|
957
960
|
transform: rotate(180deg);
|
|
958
961
|
}
|
|
959
962
|
}
|
|
960
|
-
`;var
|
|
961
|
-
${
|
|
962
|
-
${
|
|
963
|
+
`;var $K=`${nJ}
|
|
964
|
+
${tJ}
|
|
965
|
+
${eJ}`;import{jsx as D0,jsxs as d6,Fragment as lA}from"react/jsx-runtime";var xA=2,YK={activeBlockType:null,activeCommentThreadIndex:null,activeSpanKind:null,canonicalContent:"",characterCount:0,commentThreadCount:0,layoutWidth:0,resolvedCommentCount:0,selectionFrom:0,selectionTo:0};function ZK({className:$,content:Y,keybindings:X,onCommentChanged:Z,onContentChanged:J,onStateChanged:K,presence:Q,storage:M,theme:D,users:q}){let U=r1(null),V=r1(null),G=r1(null),N=r1(null),A=r1(Y),_=r1(""),z=r1(YK),[F,B]=k9(!1),{theme:W,themeStyles:S}=lJ(D),[b,k]=k9(YK),P=M1(()=>t4(Y),[Y]),y=M1(()=>v6(P),[P]),[E,w]=k9(()=>M4(P)),C=EJ(E.documentIndex.imageUrls,M),T=C.resources,H=M1(()=>[...T?.images.values()??[]].some((L)=>L.status==="loading"),[T]);N.current=E,_.current||=y;let R=aJ({editorState:E,editorStateRef:N,renderResources:T,theme:W}),{actions:u,props:g,refs:I,state:j}=R,{autoScrollDuringDrag:O,getScrollTop:v,observePreparedViewport:f,observeScrollContainer:a,prepareNextPaint:x,reconcileEditorState:E0,resolvePoint:t0,scrollTo:u0}=u,{layoutWidth:g0,preparedViewport:e0,scrollContentHeight:c6,surfaceWidth:a6,viewportHeight:D5,viewportTop:r6}=j,{scrollContainer:u2}=I,U5=M1(()=>$4(E),[E]),I0=M1(()=>S0(E),[E]),w0=M1(()=>Y0(E),[E]),s1=M1(()=>{if(!q?.length)return;return[{trigger:"@",items:q.map((L)=>({label:L.fullName??L.username,id:L.id}))}]},[q]),s6=M1(()=>sJ(q,Q),[q,Q]),i6=M1(()=>XK(E,I0.liveRanges),[I0.liveRanges,E]),i1=Boolean(J),r=()=>N.current??E,G5=k2((L,h)=>{let p=$4(L),s=S0(L),n=fJ(L),e={activeBlockType:p.block?.nodeType??null,activeCommentThreadIndex:XK(L,s.liveRanges),activeSpanKind:p.span.kind==="none"?null:p.span.kind,canonicalContent:h,characterCount:h.length,commentThreadCount:s.threads.length,layoutWidth:g0,resolvedCommentCount:W8(s.threads),selectionFrom:n.start,selectionTo:n.end};if(k((_5)=>S9(_5,e)?_5:e),!S9(z.current,e))z.current=e,K?.(e)}),t=k2((L)=>{if(!L)return;let h=N.current??E,p=h.documentIndex!==L.documentIndex,s=h5(h,L);if(N.current=L,w(L),E0(h,L),s)n6();if(!p)return;let n=s0(L),e=v6(n);_.current=e,A.current=e,J?.(e,n)}),o6=(L)=>{Z?.(L)},u9=(L)=>{let h=s0(r()).comments[L],p=h?.comments.at(-1);if(!h||!p)return;o6({kind:"added",comment:p,mentionedUserIds:D9(p.body,s1),thread:h,threadIndex:L})},JK=(L,h,p)=>{let s=s0(r()).comments[L],n=s?.comments[h];if(!s||!n)return;o6({kind:"edited",comment:n,previousBody:p,mentionedUserIds:D9(n.body,s1),thread:s,threadIndex:L})},g9=(L,h,p)=>{o6({kind:"deleted",comment:p,thread:h,threadIndex:L})},I9=k2((L=e0.peek())=>{if(!L)return;let h=b9(U.current,{paintHeight:L.paintHeight,paintTop:L.paintTop,width:g0});if(!h)return;let{context:p,devicePixelRatio:s,height:n,width:e}=h;o3(E,L,p,{activeBlockId:U5.block?.blockId??null,activeRegionId:E.selection.focus.regionId,activeThreadIndex:d9??i6,devicePixelRatio:s,height:n,liveCommentRanges:I0.liveRanges,normalizedSelection:w0,now:performance.now(),resources:T,theme:W,width:e})}),p9=k2((L=e0.peek())=>{if(!L)return;let h=b9(V.current,{paintHeight:L.paintHeight,paintTop:L.paintTop,width:g0});if(!h)return;let{context:p,devicePixelRatio:s,height:n,width:e}=h;n3(E,L,p,{devicePixelRatio:s,height:n,normalizedSelection:w0,presence:N5.presence,showCaret:w0.start.regionId!==w0.end.regionId||w0.start.offset!==w0.end.offset||n1.isVisible(),theme:W,width:e})}),KK=k2(()=>{let L=x();f(L),N5.refreshPresence(L),I9(L),p9(L)}),{scheduleContentPaint:n6,scheduleFullPaint:x9,scheduleFullRender:o1,scheduleOverlayPaint:l9}=RJ({editorStateRef:N,renderContent:I9,renderOverlay:p9,renderViewport:KK}),QK=g.getScrollContainer({onScroll:()=>o1()}),n1=AJ({canShowInsertionLeaf:Boolean(J),canShowTableLeaf:Boolean(J),commentState:I0,editorState:E,editorViewportState:e0,getScrollTop:v,layoutWidth:g0,onVisibilityChange:l9,resources:T,scrollContentHeight:c6,scrollTo:u0,viewportHeight:D5}),MK=_J(n1.imageAtCursor,E,t),V5=BJ({applyNextState:t,editorState:E,editorStateRef:N,editorViewportState:e0,inputRef:G,keybindings:X,onActivity:n1.markActivity,onImagePaste:C.persistImage}),y1=PJ({applyNextState:t,autoScrollDuringDrag:O,canvasRef:U,commentState:I0,editorStateRef:N,editorViewportState:e0,focusInput:V5.focus,onActivity:n1.markActivity,readCurrentState:r,resolvePoint:t0}),d9=y1.leaf?.kind==="comment"?y1.leaf.threadIndex:null,qK=k2((L)=>{a(L),o1()}),N5=LJ({editorState:E,editorStateRef:N,editorViewportState:e0,onViewportScroll:qK,scrollContainerRef:u2,scheduleOverlayRender:l9,userPresence:s6}),A5=gJ({applyNextState:t,autoScrollDuringDrag:O,canShowSelectionLeaf:i1,editorState:E,editorStateRef:N,editorViewportState:e0,focusInput:V5.focus,onActivity:n1.markActivity,resolvePoint:t0,threads:I0.threads}),T1=A5.handle??MK;h2(()=>{o1()},[E.documentIndex,g0,W,T,o1,D5]),h2(()=>{x9()},[w0.end.offset,w0.end.regionId,w0.start.offset,w0.start.regionId,x9,U5.block?.blockId]),h2(()=>{n6()},[i6,I0.liveRanges,d9,n6]),h2(()=>{if(!H)return;let L=null,h=window,p=()=>{o1(),L=h.requestAnimationFrame(p)};return L=h.requestAnimationFrame(p),()=>{if(L!==null)h.cancelAnimationFrame(L)}},[H,o1]);let DK=()=>{let L=y1.leaf,h=L??A5.leaf??n1.leaf,p=!L&&Boolean(A5.leaf),s=u2.current?.getBoundingClientRect()??null,n=h?.kind==="thread"?{...h,thread:I0.threads[h.threadIndex]??null}:null,e=h?.kind==="comment"?{animateInitialComment:!1,link:h.link,thread:h.thread,threadIndex:h.threadIndex}:n?.thread?{animateInitialComment:n.animateInitialComment??!1,link:null,thread:n.thread,threadIndex:n.threadIndex}:null,_5=e?.thread&&U1(e.thread)?"resolved":"default";return{annotationThreadLeaf:e,visibleLeaf:h,visibleLeafAnchor:h?{isSelection:p,left:(s?.left??0)+h.left,onPointerEnter:L?y1.leafHandlers.onPointerEnter:void 0,onPointerLeave:L?y1.leafHandlers.onPointerLeave:void 0,top:(s?.top??0)+h.top-r6+(p?xA:0)}:void 0,visibleLeafStatus:_5}},{annotationThreadLeaf:p0,visibleLeaf:A0,visibleLeafAnchor:c9,visibleLeafStatus:UK}=DK(),GK=(()=>{if(!A0)return null;switch(A0.kind){case"insertion":return D0(XJ,{onInsert:(L)=>{t(N4(r(),L))},onInsertTable:(L)=>{t(e$(r(),L))}});case"table":return D0(qJ,{canDeleteColumn:A0.columnCount>1,canDeleteRow:A0.rowCount>1,onDeleteColumn:()=>{t(YY(r()))},onDeleteRow:()=>{t(ZY(r()))},onDeleteTable:()=>{t(JY(r()))},onInsertColumn:(L)=>{t($Y(r(),L))},onInsertRow:(L)=>{t(XY(r(),L))}});case"link":return D0(QJ,{canEdit:i1,onDelete:()=>{let L=c$(r(),A0.regionId,A0.startOffset,A0.endOffset);if(L)t(L)},onSave:(L)=>{let h=d$(r(),A0.regionId,A0.startOffset,A0.endOffset,L);if(h)t(h)},title:A0.title,url:A0.url});case"create":return D0(A9,{activeMarks:A0.activeMarks,canEdit:i1,link:null,mode:"create",mentionSources:s1,onCreateThread:(L)=>{let h=r(),p=s0(h).comments.length,s=KY(h,A0.selection,L.trim());if(!s)return;t(s),A5.promoteLeafToThread(p,!0),u9(p)},onToggleBold:()=>{t(s5(r()))},onToggleItalic:()=>{t(i5(r()))},onToggleStrikethrough:()=>{t(o5(r()))},onToggleUnderline:()=>{t(n5(r()))}});default:return p0?D0(A9,{animateInitialComment:p0.animateInitialComment,canEdit:i1,link:p0.link,mode:"thread",mentionSources:s1,onDeleteComment:(L)=>{let{threadIndex:h}=p0,p=r(),s=s0(p).comments[h],n=s?.comments[L],e=qY(p,h,L);if(!e)return;if(t(e),s&&n)g9(h,s,n)},onDeleteThread:()=>{let{threadIndex:L}=p0,h=r(),p=s0(h).comments[L],s=DY(h,L);if(!s)return;if(t(s),p)for(let n of p.comments)g9(L,p,n)},onEditComment:(L,h)=>{let{threadIndex:p}=p0,s=r(),n=s0(s).comments[p]?.comments[L]?.body,e=MY(s,p,L,h);if(!e)return;if(t(e),n!==void 0)JK(p,L,n)},onReply:(L)=>{let{threadIndex:h}=p0,p=QY(r(),h,L);if(!p)return;t(p),u9(h)},onToggleResolved:()=>{t(UY(r(),p0.threadIndex,!U1(p0.thread)))},thread:p0.thread}):null}})();h2(()=>{B(!0)},[]),h2(()=>{G5(E,_.current||y)},[y,E,G5,a6]),pA(()=>{if(Y===A.current)return;let L=N.current,h=oJ(L,M4(P)),p=h.state,s=h.didReconcile?v():0;N.current=p,w(p),A.current=Y,_.current=y,u0(s)},[y,Y,P,v,u0]);let VK=$?`documint ${$}`:"documint";return D0(gZ,{themeStyles:S,children:d6("section",{className:VK,"data-active-block":b.activeBlockType??"","data-active-comment-thread":b.activeCommentThreadIndex??"","data-active-span":b.activeSpanKind??"",style:{...S,height:"100%",minHeight:0},children:[D0("style",{children:$K}),d6("div",{...QK,className:"documint-scroll-container",style:{height:"100%",minHeight:0},children:[D0("textarea",{...V5.inputHandlers,ref:G,autoCapitalize:"sentences",className:"documint-input",spellCheck:!1,tabIndex:-1}),D0(KZ,{insetX:W.paddingX,insetY:W.paddingY,onSelect:N5.scrollToPresence,presence:N5.presence}),d6("div",{...g.scrollContent,className:"documint-scroll-content",children:[D0("canvas",{...V5.canvasHandlers,...y1.canvasHandlers,"aria-label":"Documint editor",className:"documint-content-canvas",style:{cursor:y1.cursor},ref:U,tabIndex:0}),D0("canvas",{"aria-hidden":"true",className:"documint-overlay-canvas",ref:V}),T1&&d6(lA,{children:[D0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${T1.start.left}px`,top:`${T1.start.top}px`},...T1.start.props,children:D0("span",{className:"documint-resize-handle-knob"})}),D0("div",{"aria-hidden":"true",className:"documint-resize-handle",style:{left:`${T1.end.left}px`,top:`${T1.end.top}px`},...T1.end.props,children:D0("span",{className:"documint-resize-handle-knob"})})]}),A0&&c9?D0(ZJ,{anchor:c9,status:UK,children:GK}):null]}),!F?D0("div",{className:"documint-fallback",children:D0(x6,{blocks:P.blocks})}):null]})]})})}function XK($,Y){let X=new Map($.documentIndex.regions.map((D,q)=>[D.id,q])),Z=l6(X,$.selection.anchor.regionId,$.selection.anchor.offset),J=l6(X,$.selection.focus.regionId,$.selection.focus.offset),[K,Q]=Z<=J?[Z,J]:[J,Z],M=Z===J;for(let D of Y){let q=l6(X,D.regionId,D.startOffset),U=l6(X,D.regionId,D.endOffset);if(M){if(K>=q&&K<=U)return D.threadIndex;continue}if(Math.max(K,q)<Math.min(Q,U))return D.threadIndex}return null}function l6($,Y,X){return($.get(Y)??-1)*1e6+X}export{IJ as mintTheme,pJ as midnightTheme,M5 as lightTheme,j9 as defaultKeybindings,q5 as darkTheme,ZK as Documint};
|